I need to transform a camera relative to the player but not exactly as the player moves. I also can not have the player mirroring the movement of the camera. Is there a way to get the transform of an object on the same level so I can adjust the camera in the player script without affect the player?
You can create a public ‘Transform’ variable, and then assign the player to that variable.
Is that what you’re looking for?
well, in the PlayerModel class i have the PlayerMovement script which needs to change the transform of the object PlayerCamera which is not a parent or child of PlayerModel. How would I go about assigning the PlayerCamera transform inside of the PlayerMovement script?
I am using C# if that makes a difference…
You can make the assignment from the editor by choosing the appropriate object from the pop-up menu associated with the specified field in the inspector or by dragging the target object directly onto the field; or, you can make the assignment via scripting by acquiring a reference to the target object (e.g. by name, tag, or type) and assigning the reference to the specified field.
Can you give me a link to the scripting section where I can find the functions to do this?
The functions you’ll want to look at specifically are most likely Transform.Find(), GameObject.Find(), GameObject.FindGameObjectsWithTag(), Object.FindObjectOfType(), and the variants thereof.
You can find the documentation for these particular functions by searching the docs. Also, for some additional info and examples, see here.