I am trying to make a game where the player can rotate the world around them in order to escape from a maze.
At the moment i have a cube parented to the first person controller, and on a button press the cube and the world rotate in unison.
Here is the key piece of code :
function RotateWorld() {
switch(directionFacing) {
case "forward" :
transform.Rotate(Vector3(cubeRotationX * (90 * Time.deltaTime),
0, cubeRotationZ * (90 * Time.deltaTime)), Space.Self);
world.transform.Rotate(Vector3(cubeRotationX * (90 * Time.deltaTime),
0, cubeRotationZ * (90 * Time.deltaTime)), Space.Self);
break;
case "right" :
transform.Rotate(Vector3(cubeRotationX * (90 * Time.deltaTime),
0, cubeRotationZ * (90 * Time.deltaTime)), Space.Self);
world.transform.Rotate(Vector3(cubeRotationZ * (90 * Time.deltaTime),
0, -cubeRotationX * (90 * Time.deltaTime)), Space.Self);
break;
case "left":
transform.Rotate(Vector3(cubeRotationX * (90 * Time.deltaTime),
0, cubeRotationZ * (90 * Time.deltaTime)), Space.Self);
world.transform.Rotate(
Vector3(-cubeRotationZ * (90 * Time.deltaTime), 0,
cubeRotationX * (90 * Time.deltaTime)), Space.Self);
break;
case "backward" :
transform.Rotate(Vector3(cubeRotationX * (90 * Time.deltaTime),
0, cubeRotationZ * (90 * Time.deltaTime)), Space.Self);
world.transform.Rotate(
Vector3(-cubeRotationX * (90 * Time.deltaTime), 0,
-cubeRotationZ * (90 * Time.deltaTime)), Space.Self);
break;
}
}
so basically this code rotates the cube and the world based on which direction the player is facing.
is there any way i can get the world to always rotate using the player's axis? ie. so that it 'knows' which way is up?
Yeah ive been having alot of problems with the player moving through meshes and then falling through the world so i might try rotating the character instead. thanks alot for the help!
– anon25725016sorry to bring this thread back from the dead, but ive decided to continue with this project after a bit of break. im now trying to do what you suggested, to rotate the player and the forces acting upon them. the problem is rotating the player. mouselook prevents external code from rotating the player, and i havent yet been able to find a way to smoothly override this. any suggestions? (ie code?) cheers.
– anon25725016Why did u use player.up? what does it do??
– mimishakOn the other computer, have you installed the same version of the Unity Editor? Just recently I found that builds are dependent on certain .dll's that are acquired after installing Unity. I can't imagine how this issue was missed... unless it's specific to the case of our software. I've experienced this issue with both Unity 4 and 5.
– HalversonS