In this video I show how to easily set up an edgecollider2d to match the camera screen frame, then how I do the math to accurately reflect a gameobject with rigidbody2d on its surface. I show both OnTriggerEnter2D and OnCollisionEnter2D methods, which are a bit different to calculate but get similar results.
Code can be found here:
[ Ссылка ]
Disclaimer: Need to work in a solution for cases where it hits 2 colliders in the same frame.
#shorts #gamedev #mechanics #tutorial
old title: Pseudocoding Adventures 3: Reflecting Rigidbody2d Gameobjects on Screen (Unity, EdgeCollider2D)
Unity2d: bounce object off screen edge
Теги
UnityTutorialbouncereflectcollidercollisionedge2dedgecolliderrigidbody2drigidbodyunity2dunity3dcodingadventurespseudocodingprogramminggamedevtutorialsmechanicsgamedevdevelopmentcodezerokelvinphysicsvelocityvectornormalnormalizedontriggerenterontriggerenteroncolliderenteroncolliderenter2dontriggerenter2dcameramainscreenscreencolliderbilliardsputtgolf