- Home /
Making a collision between 2d objects
Hello,
I would like to know how I can make a collision between two 2d objects. The objects are simple squares. One of the squares can move, and I want to make sure it can't move onto the other square. What do I need to use to check the collision between them?
I am moving the square using transform.Translate
, is there a better way to move it?
Thanks.
Answer by Josh Naylor · Oct 10, 2014 at 02:52 PM
As this is very basic functionally I recommend you check out the learn section of the unity site. https://unity3d.com/learn/tutorials/projects/roll-a-ball
Thanks for that, it helped me out !
I do have a question about one thing. Let's say I have a field in which one of the squares can move. How do I prevent movement beyond the field? It was explained here, but I didn't exactly understand how he did it, plus he used it with the z-axis, which confused me even more.
Thanks !
Your answer
Follow this Question
Related Questions
Make player not go through walls 5 Answers
Player glitching through wall when sprinting 1 Answer
2d Platformer Jumping Not Working 1 Answer
Simple movement problem. Need units to stop dead on collision. 3 Answers
How can I make a non-player character (rigidbody) move when they touch the ground? 1 Answer