Wednesday, November 2, 2022
HomeGame Developmentrotation - Enemy turret aiming on the participant, however solely inside a...

rotation – Enemy turret aiming on the participant, however solely inside a certaina arc and with an outlined angular velocity?


So basically i’ve sport object, say its a turret and a participant object, say its a spaceship.
Proper now, each body the turret updates its rotation, so its all the time pointing on the participant. So to say, its infinite angular velocity.

What i would like is to limit the turrets aiming angle. As a instance, say the turrent could solely observe the participant inside an angle o 0 to 180 degreees (the place orientation 0 can be “to the precise”, or Vector(1, 0)).

I can do that in code, however my problem is that if the participant then enters the “monitoring arc” of the turret, the turret immediatly adjusts its rotation, seemingly “leaping” to monitoring the participant, the place as i would like it to slowly rotate in the direction of the gamers, based mostly on some “agility / angular_velocity” variable.

How can implement an “angular velocity” so my turrets rotates solely at a sure velocity ?

present code (scope turret) basically is:

operate replace(delta) 
turret.rotation = getAngleFromTo(self.place, participant.place)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments