- Home /
The question is answered, right answer was accepted
How can I call OnCollisionEnter?,
I want to use OncollisionEnter()'s "this.transform.position"in Update().
,
In general: You don't. It is a callback that gets automatically called when your script is attached to a transform with a rigidbody and a collider that enters into a collision with another object.
can you provide some more details on why? and what do you mean by "OnCollisionEnter's this.transform.position" ? The transform that is accessed in there and anywhere else on the same script is always the same.
Answer by hameed-ullah-jan · Jul 16, 2019 at 07:09 AM
you cannot call OnCollsionEnter() function by yourself, it is a callback by unity physics engine which is being called whenever a gameobject collides with other objects. To be able to use OnCollisionEnter(collision other) function you must attach Rigidbody and Collider to the same object on which this script is attached.