r_unity3d | Unsorted

Telegram-канал r_unity3d - r/Unity3D

156

News about the Unity engine and project showcases from Reddit. Made possible with @reddit2telegram (@r_channels).

Subscribe to a channel

r/Unity3D

Respawn issue

Hi, I am a beginner trying to create code that will respawn the player at the last platform they were on. But for some reason when I go to a new platform, the prefab is being changed to null, because I get a message saying the prefab hasn't been assigned. My debug code tells me that the collisions are being detected with each platform.

All the platforms are sprites with RigidBody2Ds with BoxCollider2D components. They have no scripts attached to them.

Bug behavior recording

Inspector screenshot

Thank you in advance for any help or insight you can provide! Please let me know if I screwed up any etiquette -- this is my first post here.

Here is the script attached to my Player

using UnityEngine;

public class Player : MonoBehaviour
{
// Set the speed and jumping variables
public float speed = 5.0f;
public float jumpForce = 10.0f;
public float doubleJumpForce = 60.0f;
private int jumpcount = 0;

public GameObject playerPrefab; // Reference to the player prefab
public float respawnYOffset = 300f; // Vertical offset for respawning above the platform

private Rigidbody2D rb;

private GameObject lastPlatform;

void Start()
{
rb = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
// Check if the player has fallen off the screen
float bottomEdgeY = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0f, Camera.main.nearClipPlane)).y;

if (transform.position.y < bottomEdgeY)
{
Debug.Log("Player fell off the screen!");
Debug.Log("Falling off. Last platform: " + (lastPlatform != null ? lastPlatform.name : "null"));
RespawnPlayer();
};

// Input movement
if (Input.GetKey(KeyCode.A))
{
transform.position += Vector3.left speed Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += Vector3.right speed Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Space) && jumpcount == 0)
{
rb.AddForce(Vector2.up jumpForce, ForceMode2D.Impulse);
jumpcount++;
}
else if (Input.GetKeyDown(KeyCode.Space) && jumpcount == 1)
{
rb.AddForce(Vector2.up
doubleJumpForce, ForceMode2D.Impulse);
jumpcount = 0;
}
}

private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
Debug.Log($"Collision ENTER detected with: {collision.gameObject.name}");
lastPlatform = collision.gameObject;
Debug.Log($"Last platform updated to: {lastPlatform.name}");
}
}
private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
Debug.Log($"Collision EXIT detected with: {collision.gameObject.name}");
}
}

private void RespawnPlayer()
{
Debug.Log("playerPrefab: " + (playerPrefab != null ? "Assigned" : "Null"));
if (lastPlatform != null) // Ensure there's a valid platform to respawn on
{
// Calculate respawn position
Vector3 respawnPosition = lastPlatform.transform.position;
respawnPosition.y += respawnYOffset; // Add Y offset to spawn above the platform

// Destroy the current player GameObject (if necessary)
Destroy(gameObject);

// Instantiate a new player at the respawn position
Instantiate(playerPrefab, respawnPosition, Quaternion.identity);

Debug.Log("Player respawned at: " + respawnPosition);
}
else
{

Читать полностью…

r/Unity3D

1 vs 7 battle in my game! Enemies surround the target and do not allow him to escape, so be prepared!

https://redd.it/1i4d6xg
@r_Unity3D

Читать полностью…

r/Unity3D

What do you think about embedded documentation in Unity Assets?
https://redd.it/1i4a6kp
@r_Unity3D

Читать полностью…

r/Unity3D

Added zombie death animation and headshot effect
https://redd.it/1i490ba
@r_Unity3D

Читать полностью…

r/Unity3D

The new trailer for my game! My demo is now available on Steam. Can you give me feedback on my game demo and the trailer?

https://www.youtube.com/watch?v=FX0kzVgwVW0

https://redd.it/1i46iml
@r_Unity3D

Читать полностью…

r/Unity3D

Billiard / 8Ball Asset See down below!

https://redd.it/1i3yvw7
@r_Unity3D

Читать полностью…

r/Unity3D

We are developing a slice of life game, based on an Indian city by the riverbank.

We have been off the grid for what seems like an eternity. It's about time we reveal what we've been creating.

Here's a very early glimpse of the art.

https://preview.redd.it/b6th0g9fppde1.png?width=1543&amp;format=png&amp;auto=webp&amp;s=f1ece9a2aa8be2c7ea6e6b2475b2453a39cc833b



https://redd.it/1i433tj
@r_Unity3D

Читать полностью…

r/Unity3D

Will I be in trouble if I use UnityEvents a bit too much

I always use unity events for my prototypes and other project and I just saw in a video that using those will cause peformance issue. Idk if it's true and all and that's why I am here. Will it cause performance issue? And if so how many is too many to be used?

https://redd.it/1i3xyu5
@r_Unity3D

Читать полностью…

r/Unity3D

Fur receiving multi bounce real time global illumination from mesh lights in URP RenderGraph

https://redd.it/1i3qsrd
@r_Unity3D

Читать полностью…

r/Unity3D

Basketball Arena for Unity

https://redd.it/1hr1ghq
@r_Unity3D

Читать полностью…

r/Unity3D

First-Person Aim Assist Demo (code in comments)

https://redd.it/1hqw79v
@r_Unity3D

Читать полностью…

r/Unity3D

🎮 First Trailer ✨ | Just for Fun, How Does It Look?

https://redd.it/1hqtp64
@r_Unity3D

Читать полностью…

r/Unity3D

Seeking someone to help with his/her/their project

Is there anyone who can benefit from help of Unity/C# programmer even if beginner on his/her/their project? Ping me :)

https://redd.it/1hqslw6
@r_Unity3D

Читать полностью…

r/Unity3D

This is my first Essential project completed in Unity



https://redd.it/1hqpf74
@r_Unity3D

Читать полностью…

r/Unity3D

Is there a way to reuse a component dump data?

I had a particle effect that I really wanted to imitate, so I just ripped the game and got a dump data of the particle system. But now the problem is that I have no idea how to reuse this in my Unity. I can recognize some values, but overall, it is too hard to read. Is there a way to reuse this dump data in my project easier? Such as a code or a library that someone who's like me already made.

Also, is there a way to make a .dat data readable like a dump data? I also have no idea how to convert the raw .dat to a readable file.

The dump data I want to reuse:

ParticleSystem Base
PPtr<GameObject> m_GameObject
int m_FileID = 0
SInt64 m_PathID = 19324683920102394829
float lengthInSec = 5
float simulationSpeed = 1
int stopAction = 0
int cullingMode = 3
int ringBufferMode = 0
Vector2f ringBufferLoopRange
float x = 0
float y = 1
int emitterVelocityMode = 0
bool looping = True
bool prewarm = False
bool playOnAwake = True
bool useUnscaledTime = False
bool autoRandomSeed = True
MinMaxCurve startDelay
UInt16 minMaxState = 0
float scalar = 0
float minScalar = 0
AnimationCurve maxCurve
vector m_Curve
Array Array
int size = 0
int m_PreInfinity = 2
int m_PostInfinity = 2
int m_RotationOrder = 4
AnimationCurve minCurve
vector m_Curve
Array Array
int size = 0
int m_PreInfinity = 2
int m_PostInfinity = 2
int m_RotationOrder = 4
int moveWithTransform = 1
PPtr<Transform> moveWithCustomTransform
int m_FileID = 0
SInt64 m_PathID = 0
int scalingMode = 1
int randomSeed = 0
InitialModule InitialModule
bool enabled = True
MinMaxCurve startLifetime
UInt16 minMaxState = 3
float scalar = 0.7
float minScalar = 0.5
AnimationCurve maxCurve
vector m_Curve
Array Array
int size = 0
int m_PreInfinity = 2
int m_PostInfinity = 2
int m_RotationOrder = 4
AnimationCurve minCurve
vector m_Curve
Array Array
int size = 0
int m_PreInfinity = 2
int m_PostInfinity = 2
int m_RotationOrder = 4
...

The .dat file I want to make readable:

GWh\ @ €? €?
...

https://redd.it/1hqoa54
@r_Unity3D

Читать полностью…

r/Unity3D

Making a Weather System in Unity | Coding Tutorial
https://www.youtube.com/watch?v=UNP5wEqLKmM

https://redd.it/1i49cws
@r_Unity3D

Читать полностью…

r/Unity3D

4 months in 1 minute! 🎮 From day one to now. Morning Star

https://redd.it/1i4br55
@r_Unity3D

Читать полностью…

r/Unity3D

New video breaking down how I made $500,000 from my Unity game. What do you think?

I just posted a new video covering the performance of my first commercial Unity project, This Means Warp (approx $500k net revenue).

Hope it's interesting for any indie devs looking at making a living from games. Happy to answer any questions so if you're curious just drop a comment and I'll share as much as I can!

https://redd.it/1i47odx
@r_Unity3D

Читать полностью…

r/Unity3D

Collectibles - UI communication in Unity ECS and animation with DOTween + MVC pattern 🍻
https://redd.it/1i482l5
@r_Unity3D

Читать полностью…

r/Unity3D

Anyone know who this cameo is? Or am I the only one who is old!

https://redd.it/1i44zkq
@r_Unity3D

Читать полностью…

r/Unity3D

This may be the worst thing I've ever made

https://redd.it/1i43pk2
@r_Unity3D

Читать полностью…

r/Unity3D

Working a fake point light using a decal technique.
https://redd.it/1i3rpmn
@r_Unity3D

Читать полностью…

r/Unity3D

How would I recreate the Flame of Frenzy effect in Unity? (More details below)
https://redd.it/1i3ttlj
@r_Unity3D

Читать полностью…

r/Unity3D

Ivy prefabs using APVs
https://redd.it/1i3mqel
@r_Unity3D

Читать полностью…

r/Unity3D

Happy New Year! To Welcome the fantasy 2025, I made a Star which is made up with a lot of randomly-generated GameObject. Each GameObject has a Mesh and a Trail Renderer and moves by some function. Hope you like it!

https://redd.it/1hqyph7
@r_Unity3D

Читать полностью…

r/Unity3D

The Hoard Workshop part two: Thank You for the Incredible Support!

Hey fellow devs,

First off, I want to thank everyone for the immense support on this idea (the YouTube channel incase you missed it look at my last post here:)). I honestly didn’t expect much when I posted, but you’ve all blown me away. A special thanks to the mods for not smiting me—seriously, you’re legends!

So, here’s the deal: I’m seriously doing this. Nearly 100 subs on my placeholder channel already?! You’re all incredible. I want the first video to be worth it, so I’m aiming for about a week or two to put it out. The format will be more of a retrospective vibe with gameplay clips. I don’t want to just play the games straight through—that way, people still have a reason to try them themselves. (I’m still gonna play it all though, or as much as I can! Just not give it all away)

If you want your game featured, submit it through this form: https://forms.gle/Ex4yvGi3KvziVUPi6
Here are a few things to keep in mind:

• One game per person for now—gotta keep things manageable.
• It can be any kind of game (as long as it’s not too NSFW, please).
• Don’t be shy. You are good enough, and so is your game and your skills. I’d love to check out whatever you’ve made.

Here’s the placeholder channel link again: TheHoardWorkshop" rel="nofollow">https://www.youtube.com/@TheHoardWorkshop
Thank you all so much for this overwhelming support. I can’t wait to dive into your games and show the world what you’ve created!

https://redd.it/1hquff4
@r_Unity3D

Читать полностью…

r/Unity3D

More details of my first game, now on a bigger screen
https://redd.it/1hqtsjm
@r_Unity3D

Читать полностью…

r/Unity3D

How can I recreate the wind effect in Unity?

https://x.com/MrPodunkian/status/1853991067257020868

https://redd.it/1hqren6
@r_Unity3D

Читать полностью…

r/Unity3D

Hit That Desert Drift!

https://redd.it/1hqms6f
@r_Unity3D

Читать полностью…

r/Unity3D

he's trying his best

https://redd.it/1hqlogs
@r_Unity3D

Читать полностью…
Subscribe to a channel