make 2 objects on 2d to collide with each other
Im just looking to get to 2d characters to avoid passing through each other , i tried adding rigidbody2d, box colliders ,but wasnt succesful.
I just want a normal collision like a 2d rpg ... but also I want the collision to trigger an event with ontriggerenter2D
thank you for the help
show us your code you might missed something & don't make the collider component is trigger because this is what "is trigger" about unless you code something when they collide & Ontriggerenter2D
not ontriggerenter2D
.
Thank you, now one of them get pushed when colliding with the player, I want it to stay static, any idea?
Answer by Zoogyburger · Mar 19, 2016 at 07:09 PM
You need 2d colliders (not trigger) and 2d rigidbodys on both objects and set IsKinematic on one of the Rigidbodys. You can always use OnColisionEnter2D to call an event http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html
Thank you, now one of them get pushed when colliding with the player, I want it to stay static, any idea?
Do NOT check Is$$anonymous$$inematic on the Player's Rigidbody2D and the other character check Is$$anonymous$$inematic
i think the problem is the way im moving the character in my character controller script I have if (Input.Get$$anonymous$$ey ("up")) { transform.Translate (Vector3.up * speed); WalkAnimation (0, 1, true); and that allows the character to actually go through the collider2d no matter way, any idea? it seems there is a bit of friction but it still manages to get past the walls...
ok figured out the problem, i only had to move the character with the rigidbody rather than translating it
Yes, the trick was adding velocity which makes sense as that would craft the collision with the static coliders