[Solved] floats for projectile speed and fire rate have no apparent effect

Observed behavior:
Lasers fire and move up along the y axis, but they move very slowly and are not affected by changes in the laserSpeed float. Similarly, the lasers fire at a set rate that is not affected by the fireRate float.

Expected behavior:
Lasers should fire and move along the y axis faster as laserSpeed is increased and at slower as laserSpeed is decreased. Similarly, the lasers should fire more rapidly as fireRate decreases and less rapidly as fireRate increases.

Attempted fixes:
I tried changing the new Vector3 in Fire to be floats (0f instead of just 0), but it didn’t have any effect.

Here is a link to my script:
http://pastebin.com/qyi5EDvB

Here is a screen capture of my inspector:

I don’t know for sure but, did you check laserBlue’s RigidBody2d settings in its Inspector? Maybe it still has non-zero gravity / drag or something like that.

Thanks for replying and getting my thought process back to the UI, Wendel. I discovered that the ship in my scene was not an instance of my prefab. Once I corrected that, everything worked as intended.

2 Likes

Privacy & Terms