- Home /
Player not staying on moving spaceship
Im making this space game and when you flip a swich on the spaceship it should start moving forward and then the player can move around the spaceship while the spaceship is moving. I got the spaceship to move but the player wont stay on the moving spaceship but the ship moves under the player. Ive been searching for answer but everybody says that i should just set the player as spaceship's child but its not working.
Also when i set the player as the spaceship's child the players movement gets reversed
Answer by Kakkapylly · Apr 11 at 06:56 PM
Finally found out the solution!! I just had to check Auto Sync Transforms in Project Settings/Physics
Answer by MarekRimal · Apr 11 at 11:45 AM
Yeah, parenting the player to the spaceship should do the job. If that is not happening then something else must be going on. My guess is that you are changing players position and not localPosition since now he is a child so you have to use localPosition. This can lead to strange behaviour. If its not the case then provide a screenshot of your hierarchy and the player movement script.
void Update() {
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move, speed * Time.deltaTime);
This is my movement, i dont even know if its changing local position or not :l
You are not really accessing the GameObject's local position, although I recommend doing the comment's suggestion to see any differences, I see you already fixed it, but it's worth a try!
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
2d Movement Jumps to the Left 3 Answers