- Home /
Transferring rigidbody velocity/rotation to another rigidbody
For a multiplayer game I am making I want to have a large space ship that can be controlled and navigated around by the captain while other members can freely move around to go to another post for example.
My problem is that just copying the velocity or rotation like this works very poorly:
Player.velocity = Ship.Velocity;
Using RotateAround and copying the inertia as well I was able to create the right results. But only if the velocity and rotation of the ship where manually changed. If the ship would interact with physics like a colliding object then my used methodes would not work.
How would I be able to copy pivoted velocity and rotation from the ship to the player?
Answer by SalsaDodo · May 27, 2018 at 08:42 AM
You could set the ship as the player's parent.
Example:
player.transform.parent = ship.transform;
Players will then move along with the ship, while still being able to freely move around within the ship. However, should the ship collide with something, the players will not be thrown all over the place. Which might or might not be a good thing, depending on what you want to happen. :)
I can support SaladDodger suggestion though i'd advise to be carefull since i think you want to use rigidbodys on your "crewmembers" as well. Parenting Rigidbodys is supported in the newest unity versions from what i saw, but sometimes results in weird bugs. Like collision detection between parent and child. So think of that if you choose to use this solition.
Your answer
![](https://koobas.hobune.stream/wayback/20220612163459im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D rigidbody velocity relative to rotation? 0 Answers
Projetil rotation in straight line trajectory 2 Answers
How to set Rigidbody2D velocity based on rotation 1 Answer
How can I get local 2d Velocity? 2 Answers
Rotate Rigidbody 2D towards velocity 1 Answer