Instantiate and shoot and Arrow

Hi,

Sorry to make such a huge question, but I’ve been struggling with this for three weeks and can’t seem to figure it out.

I’m still learning to write code, so bear with me…

I have a character that moves with the mouse, there is no problem there.

On mousebuttondown it’s supposed to instantiate an arrow and on MousseButtonUp the arrow fires…

So, I have on a scritp attached to the Character that goes like this:

void Update ()
	{
		if (Input.GetMouseButtonDown (0)) {

			GameObject ArrowToShoot = (GameObject) GameObject.Instantiate (arrow, ShotOrigin.position, new Quaternion (0f, 0f, 0f, 0f));
			ArrowToShoot.transform.parent = Player.transform;
			gameObject.animation.Play("PrepArrow");
		}

Then on the arrow prefab I have a script that goes like this:

void Update () {

		if (Input.GetMouseButtonUp (0)) {
			rigidbody.velocity = transform.right * -arrowVelocity;
		}

But the thing is that even though the arrow appears it doesn’t follow the character if you hold the button down. It stays where it instantiated or sometimes dissapear just because!!!

Why doesn’t it follow the character?

This is the code that moves the character just in case:

void FixedUpdate ()
	{
		float moveVertical = Input.GetAxis ("Mouse Y");
		
		Vector3 movement = new Vector3 (0.0f, moveVertical, 0.0f);
		rigidbody.velocity = movement * speed;
		rigidbody.position = new Vector3(0.0f, Mathf.Clamp(rigidbody.position.y, boundary.yMin, boundary.yMax), 0.0f);
		

	}

Use instantiate and add velocity to the arrow