[SOLVED] Using new code, cannot get projectile moving :(

Here’s my code, I honestly can’t begin to imagine what might be wrong…

	if(Input.GetButton("Fire1")) {
		GameObject Beam = Instantiate (projectile, transform.position, Quaternion.identity) as GameObject;

		projectile.GetComponent<Rigidbody2D>().velocity = new Vector3 (5, 5, 0);

	}

I hard-coded in values for x and y velocity just to make sure but the projectiles keep spawning at the ship’s position and stay there. My projectile prefab has a RigidBody2D added to it with Gravity set to 0:

FIXED: I was setting the velocity for the prefab instead of the instantiated GameObject (Beam).:slight_smile:

1 Like

Privacy & Terms