Game Development Reference
In-Depth Information
mouseLook = Camera.main.GetComponent(MouseLook_JS);
//Setup Animation
_animation[walkAnimation.name].speed = walkAnimationSpeed;
_animation[walkAnimation.name].wrapMode = WrapMode.Loop;
_animation[runAnimation.name].speed = runAnimationSpeed;
_animation[runAnimation.name].wrapMode = WrapMode.Loop;
_animation[idleAnimation.name].speed = idleAnimationSpeed;
_animation[idleAnimation.name].wrapMode = WrapMode.Loop;
}
Here, we just add the code to hide the mouse cursor, set the character movement
speed value equal to the walk speed, get the mouse look component, and set up the
animaion speed and warp mode.
3. Go to the Update() funcion and add the highlighted code ater the if
(directionVector != Vector3.zero) {} statement:
// Update is called once per frame
public function Update () : void {
// Get the input vector from keyboard or analog stick
var directionVector = new Vector3(Input.GetAxis("Horizontal"),
0, Input.GetAxis("Vertical"));
if (directionVector != Vector3.zero) {
……………
}
if (Input.GetKey(KeyCode.E)) {
//Set the maximum and minimum limit rotation on Y-axis for the
main camera
mouseLook.minimumY = minRotateY;
mouseLook.maximumY = maxRotateY;
//No Movement Direction
motor.inputMoveDirection = Vector3.zero;
} else {
//No Y-axis Rotation
mouseLook.minimumY = 0;
mouseLook.maximumY = 0;
//Change the movement speed of the character
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.
RightShift)){
int_moveSpeed = runSpeed;
} else {
int_moveSpeed = walkSpeed;
}
 
Search WWH ::




Custom Search