Ship is not centered when a child of the camera

Hello,

My ship is not centered when I put it as a child of the camera. I’ve tried applying different objects as child to the camera which work fine so I’m assuming the issue lies with the ship prefab. Only solution I can think of is putting the ship in an empty gameobject and use the new gameobject to manipulate the transform component. Hoping there is an easier solution?

Hi Scott,

The scene view is more or less irrelevant. Check the Camera Preview or the Game view. Unless I’m wrong, the ship is not visible there at all. I suspect the ship is “inside” the “lens” of the camera. Move the ship forwards along the z-axis via the Inspector and keep the game window open to see the result.

Did this help?

1 Like

Hi Nina,

Thanks for that, I can now see the ship in-game but the issue with centering still exists.

Shown in the image below the ship defaults to the left side of the screen when the game is running. I think this is because I’ve had the set the x position of the ship to 0.3 for it to be centered in the scene view, but the code below changes the x to 0 whenever I’m not controlling the ship.

I just need to understand why the ship does not center when I child it to the camera and reset the transform component.

’ transform.localPosition = new Vector3(xOffset, transform.localPosition.y, transform.localPosition.z);’

Thanks

1 Like

Change the two buttons next to the tool buttons to “Pivot | Global”. Then select the ship again to see where its pivot point is. The position in the Inspector is the position of the pivot point.

Where did you get the ship mesh from? If you created it yourself, for example, in Blender, relocate the pivot point. If you downloaded the ship, you could either edit the pivot point in Blender, or you could simply opt for your initial idea: create a new game object and parent the ship game object to it.

1 Like

This topic was automatically closed after 7 days. New replies are no longer allowed.

Privacy & Terms