- Home /
Collision detection for 2D topdown game
Hey there! I am using the following script for my character movement in a 2D topdown game:
if (Input.GetKey ("w")) {
transform.Translate(0,charSpeed * Time.deltaTime,0);
}
if (Input.GetKey ("s")) {
transform.Translate(0,-charSpeed * Time.deltaTime,0);
}
However even when a rigidbody is attached to the player, he simply seems to pass through objects. Anyone know why this could be and how to fix it? Thank you in advance!
Answer by Borzi · Jan 30, 2016 at 11:35 AM
Turns out I just had to take off the collider and put it back on again with the exact same settings...classic unity.
Answer by _Oscar · Jan 31, 2016 at 02:36 PM
Do you have colliders on the objects you're hitting? If not that could be the reason why you just pass through them.
Your answer
Follow this Question
Related Questions
How do I make my character's movement less floaty? 1 Answer
Best way to move a Rigidbody2D from point A to point B (Mouse Position) 3 Answers
Rigidboy.velocity with integer? 1 Answer
My top-down movement is really jittery, any idea how to fix? 1 Answer
Disabling diagonal movement in Unity 5 2D? (using C#) 1 Answer