0 favourites
• 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
• Hi guys!! i want to see if you could give me a hand with this one, see i ahev these enemies follow my player, but if you stay diagonal to them and let them get near you, the angle will change constantly and the will start spazzing out

i have a variable to determine the angle beetween the player and the enemy and with that i determine the way they should be looking (wich animation) i really dont know how to make the enemies go diagonal and dont change animation so weirdly

i hope you guys can help me

• Sorry, I couldn't open the .capx, I'm still on v190 - Which behaviour are you using for the motion ? Bullet ? Path planning ? Custom ?

If you're using a Bullet-type movement, you can get a simple but effective "follow" behaviour with just something like :

``````Enemy | Set Bullet angle of motion to angleRotate(Enemy.Bullet.AngleOfMotion, angle(Enemy.X, Enemy.Y, Player.X, Player.Y), angularVelocity*dt)[/code:n7kt9wge]
with angularVelocity a variable you control to cap the turn rate in degrees/sec to prevent entities from turning too quickly at short angles and get nicer trajectories.

As for getting too close to the target, I would suggest handling that with a simple finite state machine :
state 1 - far from the target > use the Bullet/Follow behaviour ; if close to target, switch to state 2
state 2 - close to the target > do something else (short range attack, etc.) ; if far from the target, switch to state 1

A "follow"-type navigation behaviour when close to the target will always cause problems (overshooting, spazzing out when trying to correct, etc.)

'hope that helps !``````
• Use a different set of angles when they are within X distance to the target (e.g. 350 to 0 and 0 to 10 means look sideways when far away but 280 to 0 and 0 to 80 means look sideways when close)... also can change the speed of how often they change direction when close vs far.

• thanks n.n you gave me some ideas, but not what im looking for, you would need to open the .capx

• could you explain a little better? or maybe show me with the .capx? it would be apreciated

i need help with this, the angle on wich the enemies turn towards me, varies constantly when going diagonally, so it goes like (North, North East, North, North East, North, North East, North, North East) and that why it starts spazzing out

• ## Try Construct 3

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

Construct 3 users don't see these ads
• Ok i made a work around, insted of moving in by the angle beetween the player and the enemy, im gogin to set the animation to the angle of motion, to see if it works, be back

• Ok i made a work around, insted of moving in by the angle beetween the player and the enemy, im gogin to set the animation to the angle of motion, to see if it works, be back

Is it working?

• 7 posts