Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class accel : MonoBehaviour
- {
- public float maxVel = 10;
- public float accelRate = 900f;
- // Update is called once per frame
- void FixedUpdate ()
- {
- Debug.Log ("before accel: " + rigidbody.velocity.magnitude);
- rigidbody.AddForce(transform.forward*accelRate, ForceMode.Acceleration);
- //fix: rigidbody.velocity = rigidbody.velocity + (transform.forward*accelRate) * Time.deltaTime;
- Debug.Log ("after accel: " + rigidbody.velocity.magnitude);
- if (rigidbody.velocity.magnitude > maxVel)
- {
- rigidbody.velocity = rigidbody.velocity.normalized*maxVel;
- Debug.Log ("after cap: " + rigidbody.velocity.magnitude);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement