|
I've got a setup where I have a block that spawns 4 turrets - 2 on top, and 2 on the bottom. I wanted to clamp them so that they could only rotate 180 degrees laterally (90 left, 90 right) and 90 degrees vertically (from straight ahead to vertically up, relative to their position) Clamping them horizontally worked okay. However, when clamping them vertically, whenever the turrets target something out of their movement range (i.e. less than 0 degrees, more than 90) they switch rapidly between their clamped values, so that they're bouncing up and down. How on earth do I get them to behave like they do horizontally? Note on the turret setup - they have two bones for movement. One is the base (horizontal) and one is the barrel (vertical) each with their own relatively simple script. I'll paste the barrel one here, as that's the one with the issue. The base script is the same, except it's all on the y axis. Also, the fire control for the turret comes from another script in the hierarchy. How can I set it so that a turret that is unable to aim at the target can't fire? (I could use a raycast on each turret, but I'm after the cheapest method possible - I intend to have lots of turrets.
(comments are locked)
|
|
Okay, here's how I fixed it (both issues in one) ceaseFire() just calls a function on the projectile generator and stops it from firing. So now my turrets have nicely clamped movement, and they don't fire when they can't "see" the player.
(comments are locked)
|
