0 Favourites

# How do I set angle towards object counterclockwise?

• 11 posts
• Hi.

When the player is on the left of the enemies, they aim at the players head. When on the right they do the same.

I wanted to restrict the "cone" of degrees that it applies.

Using the following.

Set angle toward clamp(Player.ImagePointX(2),180,230) clamp(Player.ImagePointY(2),180,230)

However since using clamp, when the player is on the right, the angle it moves at is clockwise. I need it to be anticlockwise.

I tried using the rotate anticlockwise function but this will not do as it doesn't "aim" at an object.

Is there a way to say Set angle toward clamp(Player.ImagePointX(2),Anticlockwise180,230) clamp(Player.ImagePointY(2),Anticlockwise180,230) or some solution?

• Rotate toward position and use a negative number for ccw ,worth a try ?????

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Unfortunately that doesn't work. Guess i will have to learn java script to build a new function of sorts. Not sure really

• line of sight lets you limit the cone of degrees , have you checked into using it ?

• Enemy has LOS to Player and then a subevent that checks if clockwise ,rotate to position , then a else subevent and rotate the other way , works for me !!!

• The line of sight thing doesn't work too well. It jerks the motion a lot. It snaps degrees too noticeable. Think i will redesign what i'm trying to achieve to accommodate this hiccup.

Its just frustrating considering if i do not use clamp, then there are no problems. Its only when clamp is used that it starts rotating funny.

• What exactly happens.

No Clamp everything rotates fine.

set my event like

If player X > enemy X : clamp 45 degrees left (135 - 220)

If player X < enemy X : clamp 45 degrees right (315 - 45)

I need this to work.

@Granpa can you please elaborate what exactly you did to make it work for you.

Would be much appreciated.

• i am not quite sure what you want exactly but....

try

If player X > enemy X ---------------- player set angle to anglelerp(self.angle,135,3*dt)

If player X < enemy X -------------------player set angle to anglelerp(self.angle,-135,3*dt)

feel free to change the number for it to rotate faster or slower

• What im trying to achieve is an enemy constantly aiming at the player. Like a turret. But i want to restrict it to only certain angles.

But

If player is on the left of the "enemy" it must restrict it to axis 135 - 220 degrees

If player on on right of the enemy it must restrict it to axis 315 - 45 degrees

If i do not use the clamp function then it is irrelevant if the player is on the left or right.

But when i use clamp, once the player is on the right, somehow the angle runs inverted. So if the player goes up, the enemy aim down.

In fact i do not think it is inverted. I think somehow it is still restricted to the first angle and not taking the second one into account.

It should rather be if the player goes up the enemy aims up.

I will investigate the lerp function and see if that helps my situation.

• Looks like its because i am mirroring the arms of the enemy that the angles start going lopsided and doing the inverted

• Lerp functions do not work. They simply rotate in all angles. Line of sight also doesnt work because if one enemy has line of sight it triggers all other enemies to active as well.

Is there no simple way of saying rotate towards object CCW?

• 11 posts