0
votes

I have a sphere which is moving forward by transform.translate.I want my sphere to stop moving when it is colliding with another gameobject e.g A wall.I've tried many things but can't figure out the proper way.Can anyone help me with it?Thanks in advance...

2
What did you try? Where is your code? I mean, the current code that doesn't work. You have to put something to get something - Programmer
void onCollision (Collision Collision) { GetComponent<Rigidbody> ().isKinematic = true; GetComponent<Rigidbody> ().velocity = Vector3.zero; } Thats what I've tried.Now as I put something,if you please give me somthing. - solo365
as i said in third answer it's OnCollisionEnter not onCollision. - N Fard

2 Answers

1
votes

Use OnCollisionEnter.Put in a script that is attached to your object.

OncollisionEnter

Notes: Objects should have colliders and Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.

0
votes

Does your sphere has a collider?

You should read this!

you should put more information in your question next time, like the code so we could help you out even more