Switch Position of two moving objects
Hello mates, im struggling with a little problem here. Im making some kind of Pong Game and i have two balls. What im about do is to switch position of both balls. So that ball1 has position and velocity of ball2, and ball2 has position and velocity of ball1.# I thought about saving the vector3 for each in a variable and returning them in each others script, but its really not working. Does anyone know how i should do this? :(
Setting velocity directly does work. Your code probably just isn't correct. And, as allen points out, you may have to also swap angular velocity (not sure if it matters for a perfectly round ball.)
But, it might be easier to just swap the balls' colors?
swapping the color wont do it, cause i have a smaller and a bigger ball.
Answer by allenallenallen · May 26, 2016 at 01:47 PM
How about using RigidBody component? http://docs.unity3d.com/ScriptReference/Rigidbody.html http://docs.unity3d.com/ScriptReference/Rigidbody-angularVelocity.html
Now you have access to their velocities and drag.
i already tried it via Rigidbody. and i dont need the drag cause i normalized their velocity. i just want to switch their transform position and the direction they were heading.