Testing layers and moving behind/in front of objects in 2D
I am still a beginner but I am getting there.
I managed to create an usable point & click movement with nav mesh, and now I was trying to set layers where the player goes in front/behind.
There are two game objects, one flat and wide that is used to create the obstacle in the nav mesh, and another one that includes the sprite. On the Update() I do:
if (navMeshAgent.transform.position.y > (transform.position.y - (spriteRenderer.bounds.size.y / 2)))
{
spriteRenderer.sortingOrder = 1;
}
else
{
spriteRenderer.sortingOrder = 0;
}
Is there a better way to do it? I am quite happy with the result so far, but I was wondering if I am missing something. I am also thinking of making the game object obstacle + game object sprite a prefab so I can reuse it.
https://i.redd.it/2r320whb2nfe1.gif
https://redd.it/1ibqfez
@r_Unity3D
I am still a beginner but I am getting there.
I managed to create an usable point & click movement with nav mesh, and now I was trying to set layers where the player goes in front/behind.
There are two game objects, one flat and wide that is used to create the obstacle in the nav mesh, and another one that includes the sprite. On the Update() I do:
if (navMeshAgent.transform.position.y > (transform.position.y - (spriteRenderer.bounds.size.y / 2)))
{
spriteRenderer.sortingOrder = 1;
}
else
{
spriteRenderer.sortingOrder = 0;
}
Is there a better way to do it? I am quite happy with the result so far, but I was wondering if I am missing something. I am also thinking of making the game object obstacle + game object sprite a prefab so I can reuse it.
https://i.redd.it/2r320whb2nfe1.gif
https://redd.it/1ibqfez
@r_Unity3D
Best Unity 2D Courses? 2025
Hello everyone,
I am looking for beginner courses for my little brother and would appreciate your help.
What are the best Unity 2D courses in your opinion which are most up to date?
https://redd.it/1ibe8zg
@r_Unity3D
Hello everyone,
I am looking for beginner courses for my little brother and would appreciate your help.
What are the best Unity 2D courses in your opinion which are most up to date?
https://redd.it/1ibe8zg
@r_Unity3D
Reddit
From the Unity2D community on Reddit
Explore this post and more from the Unity2D community
Reviving my old game project. I might need to rebuild it from the ground up since Unity freaked out the last time I updated. Itch link in the comments.
https://youtube.com/watch?v=_DKgbN2TTtQ&si=cIqlIKIPcv5tE3E3
https://redd.it/1ibtu3s
@r_Unity3D
https://youtube.com/watch?v=_DKgbN2TTtQ&si=cIqlIKIPcv5tE3E3
https://redd.it/1ibtu3s
@r_Unity3D
YouTube
Metro Flux 1 27 25
I made and released a free + open source tool that helps you create pixel perfect 2D shadow casters in Unity! :D Feel free to use it and let me know if you have any feedback! Github link in comments.
https://redd.it/1ibw7fa
@r_Unity3D
https://redd.it/1ibw7fa
@r_Unity3D
We're creating a roguelite deckbuilder involving cats - Tailless Frank. Wishlist now on steam - link in the comments.
https://redd.it/1ibx3u7
@r_Unity3D
https://redd.it/1ibx3u7
@r_Unity3D
Need some help with creating a shader
Does anyone know how can i make the colors move around the frame (without changing the sprite) shader graph / hlsl are both ok, I'm just can't figure it out myself. all help will be highly appreciated!
https://preview.redd.it/n0fw63l4tpfe1.png?width=975&format=png&auto=webp&s=9b691bd6cbf839fbca96be9867c9193057d18640
https://redd.it/1ibywyb
@r_Unity3D
Does anyone know how can i make the colors move around the frame (without changing the sprite) shader graph / hlsl are both ok, I'm just can't figure it out myself. all help will be highly appreciated!
https://preview.redd.it/n0fw63l4tpfe1.png?width=975&format=png&auto=webp&s=9b691bd6cbf839fbca96be9867c9193057d18640
https://redd.it/1ibywyb
@r_Unity3D