- Home /
Question by
DevMerlin · Apr 22, 2015 at 11:27 AM ·
rotationtransform.rotation
Instantiate facing world zero on Y axis?
At current I am working on the code for my player creation, which works - however, the rotation is always wrong. I can't seem to get the player to face towards WORLD zero on the Y axis, this is to ensure that they're facing the center of the map from any of it's four corners and know which way to go. What am I doing wrong with the rotation portion of my code?
public void CreateClientPlayer()
{
GameObject PlayerObj;
Vector3 SpawnPosition = Portals[1].transform.position;
Vector3 PlayerRotation = new Vector3(270, 0, 0);
Quaternion RotateTowards = Quaternion.identity;
RotateTowards = Quaternion.LookRotation(PlayerRotation);
SpawnPosition.y = 10.0f;
PlayerObj = Instantiate(Vehicles[0], SpawnPosition, Quaternion.identity) as GameObject;
Player = PlayerObj.AddComponent<PlayerController>();
Player.gameObject.transform.Rotate(270, RotateTowards.y, 0);
camera.target = Player.gameObject.transform;
camera.Init();
}
Comment
Your answer
Follow this Question
Related Questions
Rotation of object 0 Answers
how can i stop rotating gameobject but slowly 1 Answer
transform.localRotation lerp precision 1 Answer
Follow rotation on Y axis ONLY clockwise/counterclockwise. 1 Answer