- Home /
pause animation when two objects is colliding and resume when they're not colliding without rigid body?
Hello to everybody,
I'm new in this world of Unity 3D and I'm getting started with a game. The game consists in a city wich has a bus moving by animation, and i want when im front of the bus, bus will pause and when im not there the bus continues moving, i mean, resuming animation. I could do something with rigid body with this code written in javascript:
function OnCollisionEnter(collision : Collision){
if (collision.gameObject.tag == "Bus") {
collision.gameObject.animation["bus_colli_test"].speed=0;
}else{
collision.gameObject.animation["bus_colli_test"].speed=1; } }
but it just stop the rigid body and it doesn't resume the animation, and when it stops, the bus starts to do weird thing due weird physics laws. When im not front of the bus, the bus doesn't resume the animation.
So here my asks, can I make collision without rigidbody? can I pause and resume the animation when im front of the bus and when im not front of?
Please, post a sample code,
lot of thanks.
Your answer
Follow this Question
Related Questions
Unity 5: No collision with other objects after an animation? 0 Answers
i want to make an animation throw code 0 Answers
How to stop an animation on collision 0 Answers
How to have other (any) Objects smoothly push a Character Controller? 1 Answer
Playing animation frame by frame depending on speed (time) 1 Answer