Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Tortuga : MonoBehaviour
- {
- private Animator anim;
- private CharacterController controller;
- public float speed = 6.0f;
- public float turnSpeed = 60.0f;
- private Vector3 moveDirection = Vector3.zero;
- public float gravity = 20.0f;
- public string horizontalCtrl = "Horizontal_P2";
- public string verticalCtrl = "Vertical_P2";
- public float coeffSpeedUp = 1.0f;
- // Use this for initialization
- void Start ()
- {
- controller = GetComponent <CharacterController> ();
- anim = gameObject.GetComponentInChildren<Animator> ();
- }
- // Update is called once per frame
- void Update ()
- {
- if (Input.GetKey ("i"))
- {
- anim.SetInteger ("IsWalking", 1);
- } else {
- anim.SetInteger ("IsWalking", 0);
- }
- if (controller.isGrounded)
- {
- moveDirection = transform.forward * Input.GetAxis (verticalCtrl) * coeffSpeedUp;
- }
- float turn = Input.GetAxis(horizontalCtrl);
- transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);
- controller.Move(moveDirection * Time.deltaTime);
- moveDirection.y -= gravity * Time.deltaTime;
- }
- public IEnumerator StopSpeedUp() {
- yield return new WaitForSeconds (4.0f); // the number corresponds to the nuber of seconds the speed up will be applied
- coeffSpeedUp = 4.0f;
- // back to normal !
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement