Hi,
When I try to run the code with the velocity as a publicly declared variable, the lazer gameobjects fail to gain that velocity.
However if I remove the variable, and in its place, just type 10f, then the lazers DO gain the velocity.
Here is the relevant code:
public float Projectilespeed = 10f;
void Update () {
Vector3 startposition = transform.position + new Vector3(0, -1, 0);
GameObject laser = Instantiate(projectile, startposition, Quaternion.identity) as GameObject;
laser.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -Projectilespeed);
}
Any solutions would be much appreciated,
Thanks