Hey guys
I am not too sure what to search for regarding my situation, so I’m asking the question here.
I am developing a 2.5D game, and I would like the camera to rotate around the player when he enters a certain trigger. What I mean by this is that when the player enters the collider, the camera would transform and rotate from original position to the new position (which is behind the player).
Also, the player would have to rotate 90 degrees on the Y-axis, because I would like him to start walking in the Z-axis.
So essentially, I would like to make it appear as if the world has rotated along with the character, and allow the character to head into the Z-axis; making the game like 3D.
Finally, I need to know how to change the “horizontal axis” so that when the player keeps pressing “D” on the keyboard, he is still going forward. (I noticed that when I made the player rotate, he would be facing in the correct direction, but moving along the X-axis.)
If anyone can help me, that would be greatly appreciated 
Here’s my movement script:
var walkSpeed : float = 6.0;
var runSpeed : float = 10.0;
var speed : float = walkSpeed;
var jumpSpeed : float = speed * 1.7;
var gravity : float = 20.0;
var walkTime : int = 0;
var moveDirection : Vector3 = Vector3.zero;
static var grounded : boolean = false;
var controller : CharacterController;
static var flags : CollisionFlags;
var idle : boolean = false;
static var jumping : boolean = false;
var character : GameObject;
var turnedAround : boolean = true;
var facingForward : boolean = true;
var transRotation : int = 90;
var rotateAmount : float = 90;
var targetRotation : float = 0;
var currentRotation : float = 0;
var rotationSpeed : float = 2.0;
//var jumped : AudioClip;
var jumpSound : AudioClip;
function Start ()
{
animation.wrapMode = WrapMode.Loop;
animation["run"].layer = -1;
animation["walk"].layer = -1;
animation["idle"].layer = -1;
animation.SyncLayer(-1);
animation["jump"].layer = 10;
animation["jump"].wrapMode = WrapMode.Once;
animation.SyncLayer(10);
animation.Stop();
animation.Play("idle");
}
function Update()
{
if(!(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical")) && grounded)
{
animation.CrossFade("idle");
idle = true;
}
else
{
idle = false;
}
/*if(flags == CollisionFlags.None && Input.GetKeyDown(KeyCode.Space) && grounded)
{
jumping = true;
}
else
{
jumping = false;
}*/
if(moveDirection.x <0)
{
turnedAround = true;
transRotation = 270;
//transform.eulerAngles = Vector3(0,270,0);
}
else if(moveDirection.x >0)
{
facingForward = true;
transRotation = 90;
//transform.eulerAngles = Vector3(0,90,0);
}
if(CameraRotate.entered == true)
{
var directionVector = new Vector3 (0, transform.position.y, 0);
if(Input.GetKeyDown(KeyCode.T))
{
targetRotation = rotateAmount - targetRotation;
}
currentRotation = Mathf.Lerp(currentRotation, targetRotation, rotationSpeed * Time.deltaTime);
transform.eulerAngles.y = currentRotation;
}
transform.eulerAngles.y -= (transform.eulerAngles.y -transRotation)/10; //slows down time in which character turns around
}
function FixedUpdate ()
{
if(grounded)
{
jumping = false;
moveDirection = new Vector3(Input.GetAxis("Horizontal"),0,0);
moveDirection *= speed;
if(Input.GetButton("jump"))
{
jumping = true;
audio.PlayOneShot(jumpSound);
moveDirection.y = jumpSpeed;
animation.CrossFade("jump");
}
}
else
{
moveDirection = new Vector3(Input.GetAxis("Horizontal"), moveDirection.y/speed,0);//allows character to move while in mid air
moveDirection *= speed; //returns speed to normal when grounded
}
moveDirection.y -= gravity*Time.deltaTime;
controller = GetComponent(CharacterController);
flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) !=0;
if(Input.GetAxis("Horizontal") > 0.2 || Input.GetAxis("Horizontal") < 0.2)
{
if(walkTime > 40)
{
animation.CrossFade("run");
speed = runSpeed;
}
else
{
walkTime++;
animation.CrossFade("walk");
speed = walkSpeed;
}
jumpSpeed = speed * 1.7;
}
else
{
walkTime = 0;
animation.CrossFade("idle");
}
}
@script RequireComponent(CharacterController)