Rotation with axis/pivot around player

I'm making a 1st person puzzle game where you have to navigate the walls and ceiling to advance through a maze. I want the player to be able to rotate the maze around the player, using the player as its pivot; is there some way I could do this?

I had previously been trying to simply use transform.rotate on the level for rotation but I guess it moves too fast or something since the player usually ends up glitching through the mesh collider I have on the level(with rigidbody)

I am using the first person controller that came with unity to handle the movement of the player and I plan on putting the rotation script on the level since it's just one object

I thought it might have to do with how a third person camera orbits around a player but I wanted to see if there was a different way to go about it since my last endeavor ended in failure (collision detection destroys my soul)

Any help would be awesome...

1 Answer

1

if i understand what your asking right then you should use transform.RotateAround

var Player : Transform;
var RotateSpeed = 20;

function Update() {
    // spin the player around the world origin at 'RotateSpeed' degrees/second.
    transform.RotateAround (Player.position, Vector3.up, RotateSpeed * Time.deltaTime);
}

put this on your maze or rotating object and set the player to your player in the inspector

hope this helps

Scribe

for me this code makes it rotate smoothly around the player however i only used a box and a capsule to represent the maze and player so the collision are probably easier for the engine to work out I don't know what else you could try P.S do you have a rigid body on your maze because this could be the reason for the jitteriness (<-- don't know if thats a word :D )

–

You are welcome glad you managed to get it to work

–