- Home /
Making something move relative to something else, but slower/shorter ?
I have 2 objects, they both rotate the exact same, and can move in 3d space.
The 2nd object however, I want to move as well as the 1st object, but 1/100th or 1000th the speed, etc. So, can I just give Rigidbody B, Rigidbody A's velocity, or magnitude or something, divided by my movement speed ratio?
Answer by revolute · Jan 23, 2015 at 05:19 AM
Sure, why not? Make a script and attach this to your 2nd object. Assign a public variable to let your 2nd object script reference 1st object's rigidbody. Then in Update() write this single line : gameObject.rigidbody.velocity = firstObject.rigidbody.velocity * ratio;
Now it will follow the first object at its speed.
Answer by J_Troher · Jan 23, 2015 at 05:21 AM
Ah good. I wasn't sure if i could multiply/divide velocity, since its a vector4. will give it a try!
Just to keep you clear, a vector3 is a form of matrix so multiplications are limited but for integers and floats, which are simple scale calculations. For example, (a,b,c)*x == (ax,bx,cx).