//


// 

// 2013/06/07 N.Kobyasahi

//

using UnityEngine;

using System.Collections;



public class ThirdPersonCamera : MonoBehaviour

{

public float smooth = 3f;

public Transform standardPos; // the usual position for the camera, specified by a transform in the game

Transform frontPos; // Front Camera locater

Transform jumpPos; // Jump Camera locater

bool bQuickSwitch = false; //Change Camera Position Quickly

void Start()

{

//standardPos = GameObject.Find ("CamPos").transform;

if(GameObject.Find ("FrontPos"))

frontPos = GameObject.Find ("FrontPos").transform;


if(GameObject.Find ("JumpPos"))

jumpPos = GameObject.Find ("JumpPos").transform;


//繧ォ繝。繝ゥ繧偵せ繧ソ繝シ繝医☆繧

transform.position = standardPos.position;

transform.forward = standardPos.forward;

}


void FixedUpdate ()

{

if(Input.GetButton("Fire1")) // left Ctlr

{

// Change Front Camera

setCameraPositionFrontView();

}

else if(Input.GetButton("Fire2")) //Alt

{

// Change Jump Camera

setCameraPositionJumpView();

}

else

{

// return the camera to standard position and direction

setCameraPositionNormalView();

}

}


void setCameraPositionNormalView()

{

if(bQuickSwitch == false){

// the camera to standard position and direction

transform.position = Vector3.Lerp(transform.position, standardPos.position, Time.fixedDeltaTime * smooth);

transform.forward = Vector3.Lerp(transform.forward, standardPos.forward, Time.fixedDeltaTime * smooth);

}

else{

// the camera to standard position and direction / Quick Change

transform.position = standardPos.position;

transform.forward = standardPos.forward;

bQuickSwitch = false;

}

}


void setCameraPositionFrontView()

{

// Change Front Camera

bQuickSwitch = true;

transform.position = frontPos.position;

transform.forward = frontPos.forward;

}


void setCameraPositionJumpView()

{

// Change Jump Camera

bQuickSwitch = false;

transform.position = Vector3.Lerp(transform.position, jumpPos.position, Time.fixedDeltaTime * smooth);

transform.forward = Vector3.Lerp(transform.forward, jumpPos.forward, Time.fixedDeltaTime * smooth);

}

}




'Computer Language > 유니티' 카테고리의 다른 글

잼과 이동관련  (0) 2014.11.26
Hexa  (0) 2014.11.25
사인과 코사인 응용 방안  (0) 2014.11.12
Dialog() 다이아로그  (0) 2014.11.10
더미와 다이어로그  (0) 2014.11.10

+ Recent posts