- Home /
2D Sending Object From One Place To Mouse Position.
Hey,
I'm trying to make a 2D shooter where on click a bullet is fired from the player position to the current position of the Mouse (Using Raycasting). I've Instigated the prefab and can make it move using vector2, I just need to know how to store the mouse position where the bullet is going. Do I use another ray variable or raycast variable or something else? Also how do I move the bullet to that position do I still use a vector2 variable?
Thanks!
In 2D, you should not have had to raycast to find the mouse position. Can you post your Instantiate() code and the code you are using to move your bullet?
Answer by Andres-Fernandez · May 22, 2014 at 03:28 PM
Getting the Input.mousePosition and substracting the player/gun position from it gives you the direction vector. Apply force on the bullet (or change velocity or whatever you are using).