Sidescroller Bullets Follow Mouse After Being Shot

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: - YouTube .

Now the code on my PLayerScript (To find location of the mouse and instantiate the bullet)

// this creates a horizontal plane passing through this object's center
var plane = Plane(transform.position, Vector3.up);
// create a ray from the mousePosition
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// plane.Raycast returns the distance from the ray start to the hit point
var distance: float;
if (plane.Raycast(ray, distance)){
    // some point of the plane was hit - get its coordinates
    hitPoint = ray.GetPoint(distance);
    hitPoint.z = -19;
    }

direction = hitPoint - transform.position;

if(Input.GetMouseButtonUp (0) )
{
    var instantiatedbullet = Instantiate(bullet,GameObject.Find("SpawnPoint").transform.position, Quaternion.Euler(direction.normalized)); 
}

Then my code on my BulletScript to move it forwards after being instantiated.

//amount to move bullet
amtToMove = bulletSpeed * Time.deltaTime ;

transform.Translate(Vector3.fwd * amtToMove);

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?

I can’t help overhaul your code because I’m not particularly with Javascript, but is the

 if (plane.Raycast(ray, distance)){
    // some point of the plane was hit - get its coordinates
    hitPoint = ray.GetPoint(distance);
    hitPoint.z = -19;
    }

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.

Try something like this,

function Update(){ mouseX = Input.GetAxis(“MouseX”)l if (mouseX){ bulletTransform.Rotate(mouseX * Time.deltaTime * sensitivityVariable, 0, 0); } }