Basically, I am working on a networking project with a top down view.
I have a prefab player object with all of my scripts attached.
The problem is, I have a code that I have made for the camera to follow the player, but since it is network code, I am trying to get the camera to spawn with the player prefab, but not take the position of the parent.
Things I have tried/attempted:
Having the camera in the scene rather than spawning.
Spawning a separate camera prefab.
Different ways to spawn the separate camera prefab..
Also, when I had it spawned separate, it was not correctly finding my player.
Things I will try after posting and keep updated:
I am going to try changing my cameras follow code rather than the camera finding the target, I will have the target find the camera.
Also, any other information on networking cameras would be greatly appreciated, thank you.
I'm not sure I quite understand what you're doing, but your basic question "How can I prevent position of a child transform to be hooked to the parent in a prefab?" is easy to answer. A child transform is entirely relative to its parent - its position is relative to the parent position, its rotation is relative to the parent rotation, and its scale is relative to the parent scale. There is no way to 'uncouple' a child from its parent other than to remove the parent/child relationship. You can't do that within a prefab - you have to do it after the prefab is instantiated in scene. Here's how you uncouple a parent/child prefab:
Instantiate the prefab.
On the child, set 'transform.parent = null;' The child is no uncoupled - it has no parent.
Then, set the 'transform.position' to wherever you want it to be.
Just FYI, transforms and parenting have nothing to do with networking (I assume that by networking you mean "sending information over a network."
answered Dec 14 '11 at 10:39 PM