- Home /
Question by
andy_pondy · Dec 13, 2017 at 10:52 PM ·
unity 5collision
move target gameobject on collision with projectile
hi,
i have a simple player game object from the basic multiplayer tutorial . i want to make more modifications to it to learn some collision.
what i want to do is OnCollisionEnter i want to move the target gameobject to a certain distance. to simulate contact. so basically push the game object in the direction of the bullet for a short distance.
how do i get the speed of the bullet it was moving with and apply a small push and stop on the target player?
Comment
Answer by DeusIgnis · Dec 13, 2017 at 11:45 PM
I believe you are looking for the velocity from the rigidbody component. Rigidbody.velocity If I'm not mistaken, that value will return a vector3 that you can then use to add a force on the player.
Hope this is what you are looking for.
Your answer