So after I instantiate my bullets and fire towards my mouse in this sidescroller, the bullets continue to follow the mouse. If you move the mouse left, the bullets will curve left. The speed of the bullets will also be slower if you shoot close to the player, because the bullet wants to stay around the mouse. Here's a short video so you can visualize my problem: http://youtu.be/tT09CA-pY9M .
Now the code on my PLayerScript (To find location of the mouse and instantiate the bullet)
direction = hitPoint - transform.position;
Then my code on my BulletScript to move it forwards after being instantiated.
So how do I have the bullet remember the spot the cursor was at when the mouse button was clicked up, and only move to and then past that point?
asked May 15 '12 at 12:53 AM
block in the Update function, and is hitPoint global? If both are true it looks like a new hitPoint is generated every update based on wherever your mouse is at the time. Trying firing multiple bullets at once and see if they all follow the mouse.
Try passing a copy of the hitPoint to the bullet of using a global.