#Trying to get bullet to move where I click the mouse

1 messages · Page 1 of 1 (latest)

dreamy terrace
#

Not sure how to get the vector2 right.

    {
        //todo: set vector to mouse position
        bulletRB.AddForce(Vector2.right * bulletSpeed, ForceMode2D.Impulse);

        if (transform.position.x > destroyBoundary || -transform.position.x < -destroyBoundary || transform.position.y > destroyBoundary || -transform.position.y < -destroyBoundary)
        {
            Destroy(gameObject);

        }
    }```

the Vector2.right dictates the bullet's current trajectory. Trying to just input a Vector2 with Input.mousePosition.x and y has the bullet not even load in my game.
#

When I change the Vector2.right to down or left, it follows so I know the Vector2.right is where I need to get the input.

#

on a side note, I also am having trouble destroying the bullet when it is shooting down.

#

well I figured out the destroy problem

dreamy terrace
#

I am testing out with Vector2.MoveTowards right now