0 Favourites

Problem with angle of enemies, please help :P

  • 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.

  • Refeuh

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

  • ggibson1

    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

  • Construct 3

    Buy Construct 3

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

    Buy Now 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
300 118,427
blackhornet's avatar
blackhornet
Unread hot topic
157 12,693
megatronx's avatar
megatronx
Unread hot topic
0 Favourites
Kiira will help! :D
132 16,619
Kiira's avatar
Kiira