This is the only method of movement that I can get to work and I would rather not have acceleration but I’m stuck with it for now… How can I limit the acceleration so it doesn’t accelerate infinitely or better yet remove acceleration altogether WITHOUT scraping this method of movement?
using UnityEngine;
using System.Collections;
public class SimpleMovement : MonoBehaviour
{
public Vector2 thrustBackward;
public Vector2 thrustForward;
public Vector2 thrustUp;
public Rigidbody2D rb2D;
void Start ()
{
thrustBackward = new Vector2 (-10, 0);
thrustForward = new Vector2 (10, 0);
thrustUp = new Vector2 (0, 10);
rb2D = GetComponent<Rigidbody2D> ();
}
void Backward ()
{
rb2D.AddForce (thrustBackward, ForceMode2D.Force);
}
void Forward ()
{
rb2D.AddForce (thrustForward, ForceMode2D.Force);
}
void Jump ()
{
rb2D.AddForce (thrustUp, ForceMode2D.Impulse);
}
void Update ()
{
if (Input.GetKey (KeyCode.LeftArrow))
Backward ();
if (Input.GetKey (KeyCode.RightArrow))
Forward ();
if (Input.GetKeyDown (KeyCode.UpArrow))
Jump ();
}
}