Set a prefabs GameObject

Hey everyone!

Might have a tricky one here! For my player, I’ve made 2 Objects, the first one is for the camera and the other is for the body (so that the body doesn’t rotate on it’s x axes and only on it’s y). Neither of them is the parent of the other. The camera follows the body.

Time for the problem. At the start of the scene want to instantiate them but, the camera doesn’t pick up the body so it can follow it. I have to set it in game and it doesn’t set it self automatically. I’m using the public Transform body; and telling it to have the same position as it. Any Idea of how I can fix this?

Thanks everyone for your help!

You could create the following hierarchy and just instantiate the InstantiatedObject (empty GO with your two objects as children):

  • Instantiatedobject
  • player
  • camera