public void GetAIInput() { // calculate steering amount steer = Mathf.Clamp(AIController.GetHorizontal(), -1, 1); // how much accelerator? motor = Mathf.Clamp(AIController.GetVertical(), 0, 1); // how much brake? //brake= -1 * Mathf.Clamp( AIController._input.GetVertical(), -1, 0 ); }
// main event void Update() { // turn the transform, if required myTransform.Rotate(new Vector3(0, Time.deltaTime * AIController.GetHorizontal() * turnSpeed, 0)); // if we have a rigidbody, move it if required if (myBody != null) { myBody.AddForce((myTransform.forward * moveSpeed * Time.deltaTime) * AIController.GetVertical(), ForceMode.VelocityChange); } }
public void GetAIInput() { // calculate steering amount steer = Mathf.Clamp(AIController.GetHorizontal(), -1, 1); // how much accelerator? motor = Mathf.Clamp(AIController.GetVertical(), -1, 1); // THIS IS IMPORTANT! As we are a wheeled vehicle, the engine needs to drive to turn when stopped if (AIController.currentAIState == AIState.stopped_turning_left || AIController.currentAIState == AIState.stopped_turning_right) { // back up motor = 0.4f; } }