Instantaneous acceleration of 2D objective unity in the right direction, depending on the corner



  • That's the code I got. The area is down, in AddForce. Do you want her or can you do something different?

    private ArrowRotation zRotateArrow;
    private Rigidbody2D rb2D;
    

    private Vector3 vcMove;
    public float speed;

    public GameObject ArrowObj;

    void Awake()
    {
    zRotateArrow = ArrowObj.GetComponent<ArrowRotation>();
    rb2D = GetComponent<Rigidbody2D>();

    speed = 28f;
    

    }

    void FixedUpdate()
    {
    if (Input.GetKeyDown(KeyCode.A))
    {
    transform.Rotate(0f, 0f, zRotateArrow.rotateZ);
    rb2D.AddForce(this.transform.up, ForceMode2D.Impulse);
    }
    }



  • In order to give instant acceleration, it is necessary to use not AddForce, but to place velocity on the required value.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2