- Home /
want to knock gameobject to the same direction as the projectile
Hello im very new to unity I want to knock the gameobject to the same direction as the projectile but unfortunately i was able to knock it horizontally and vertically. im unable to knock it at angle and also this is a 2d game.
any help is much appreciated!
Do you really want to send the blue ball in the same direction as red ball? That would look unnatural. $$anonymous$$ost likely, if you use rigidbody, you pretty much have nothing to do. You send the red ball and let the engine do the rest.
Though if you are in the case the blue should take the red velocity well I just gave you the answer.
Whatever is the velocity of the red is passed to the blue on collision. If you are translating the red then the vector parameter is the velocity, if you use rigidbody you have teh velocity in
blue.rigidbody2D.velocity = red.rigidbody2D.velocity;
no i mean the red ball shoot projectile to hit the blue ball and knock the blue ball to same as the projectile direction that the red ball shoot but i already try with rigidbody would not knock it to the same direction as the projectile that the red ball shoot or maybe i do sth wrong
So your red ball is probably translated with something like:
transform.Translate(direction * Time.deltaTime);
direction * Time.deltaTime in this case is your velocity.
Answer by Notter · Jun 08, 2015 at 11:37 AM
they do something similar to to what you're asking in this video, about half-way. they shoot a bear with a capsule collider, and apply force where the "projectile" hit, and send the bear flying in that direction.
http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/fun-with-lasers