This is my code so far, i was wondering if there is a way to make the character start off the game running?
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(CharacterController))]
public class AdvancedMovement : MonoBehaviour {
public float walkSpeed = 5;
public float runMultiplier = 2;
public float strafeSpeed = 2.5f;
public float rotateSpeed = 250;
public float gravity = 20;
public CollisionFlags _collisionFlags;
private Vector3 _moveDirection;
private Transform _myTransform;
private CharacterController _controller;
public void Awake() {
_myTransform = transform;
_controller = GetComponent<CharacterController>();
}
// Use this for initialization
void Start () {
_moveDirection = Vector3.zero;
}
// Update is called once per frame
void Update () {
if(_controller.isGrounded) {
Debug.Log("On the ground.");
_moveDirection = new Vector3(0,0, Input.GetAxis("Move Forward"));
_moveDirection = _myTransform.TransformDirection(_moveDirection).normalized;
_moveDirection *= walkSpeed;
}
else{
Debug.Log("Not on the gorund.");
if((_collisionFlags & CollisionFlags.CollidedBelow) == 0) {
}
}
_moveDirection.y -= gravity * Time.deltaTime;
_collisionFlags = _controller.Move(_moveDirection * Time.deltaTime);
}
}