I’m trying to match the rotation of my player to the rotation of a spawnpoint and this doesn’t seem to be working:
targetCharacter.transform.rotation = spawnPoint.transform.rotation;
I’m trying to match the rotation of my player to the rotation of a spawnpoint and this doesn’t seem to be working:
targetCharacter.transform.rotation = spawnPoint.transform.rotation;
“I’m trying to match the rotation of my player to the rotation of a spawnpoint and this doesn’t seem to be working”
Care to define how it doesn’t seem to be working?
Like the code is not running at all?
Or the resulting rotation isn’t what you expected?
Something else?
To set transform’s rotation, you only need to do:
this.transform.rotation = otherTransform.rotation;
Sorry I wasn’t specific enough. No errors in the code, the rotation is not what I expected. I tried changing the code to this:
targetCharacter.transform.rotation = spawnPoint.rotation;
I get the error:
Error CS1061 ‘GameObject’ does not contain a definition for ‘rotation’ and no accessible extension method ‘rotation’ accepting a first argument of type ‘GameObject’ could be found (are you missing a using directive or an assembly reference?)
Sounds like your spawnPoint field is a GameObject type… not transform?
If so, try this instead (or change your field’s type to Transform):
spawnPoint.transform.rotation;
Edit: in your OP you had it like that…
It would be best if you showed your complete code instead of single line.
It is a game object. Is it possible to get the reference the gameobject’s transform and match the rotation that way?