Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Cant addforce

FoguFogu Member
edited April 16 in Programming

I want to create an Instantiate and addforce to that Instantiate, but when I try to addforce nothing happens. There no error message telling me what wrong. What can I do?

Here is the code:


  void bullet()

  {

    if (Input.GetMouseButtonDown(0))

    {

      GameObject bulletclone = Instantiate(bulletob);

      bulletclone.transform.position = transform.position;

      bulletclone.transform.rotation = transform.rotation;

      rb = GameObject.Find("Bullet(Clone)").GetComponent<Rigidbody2D>();

      rb.AddForce(transform.forward * Time.deltaTime * thrust, ForceMode2D.Impulse);

    }

  }

Answers

  • NeigeNeige Member

    Maybe try to multiply the transform.forward with the thrust

Sign In or Register to comment.