Can't rotate PlayerController

Started by Zacoriot 2 posts 86 views

Reply on sbox.game
  1. edited Apr 2026 #1
    Zacoriot 435
    Heya!

    Just a quick one, as  I am not sure if I am going about this the correct way. I am trying to set my players position and rotation to a given Vector3 and Quaternion provided and stored by a checkpoint.
    void Respawn(GameObject player)
    {
    	if( _MyRagdoll != null)
    	{
    		_MyRagdoll.Destroy();
    	}
    
    	_MyRagdoll = player.GetComponent<PlayerController>().CreateRagdoll();
    
    	player.WorldPosition = _Position;
    	player.WorldRotation = _Rotation;
    }
    My issue is that my player teleports to the correct position but does not rotate properly and retains the original look direction.

    I have tried enabling and disabling the: player game object; PlayerController Component to no avail

    If anyone has any advice that would be great! :)
    edited:
    SOLVED: I had to rotate the camera to get around the issue:

    void Respawn(GameObject player)
    {
    	if( _MyRagdoll != null)
    	{
    		_MyRagdoll.Destroy();
    	}
    
    	_MyRagdoll = player.GetComponent<PlayerController>().CreateRagdoll();
    
    	player.WorldPosition = _Position;
    	Scene.Camera.WorldRotation = _Rotation;
    }

  2. #2
    bosinn 35
    Please, always set explicitly access modifiers and don't name field and properties with _CamelCase 😢 Read microsoft coding convention