I am trying to control a cube with the keyboard inputs. I want to change the acceleration of the cube while it is in the air, but the applied forces will only update during a collision or if I set the drag to a large value. I have included my code below.
using UnityEngine;
using System.Collections;
public class CubeMove : MonoBehaviour {
private Vector3 input;
private float maxSpeed=5f;
private float accelSpeed=500f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
input=new Vector3(Input.GetAxisRaw("Horizontal"),0,
Input.GetAxisRaw ("Vertical"));
if(rigidbody.velocity.magnitude<maxSpeed){
rigidbody.AddForce(input*accelSpeed,
ForceMode.Acceleration);
print(rigidbody.velocity);
}
}
}