Changing enemy animations....omg

So I’m making an isometric shooter. And I can’t figure out how to make the enemies change direction to the player. I followed the tank tutorial and all it has is some stuff about rotating the tanks.
I don’t want to rotate because it’s not top down, it’s ISOMETRIC!
I want them to change between their 4 animations relative to the players position next to them. Left, right, up, down.!
help|690x361

I’m new to Gdevelop, but maybe you could try storing the player’s coordinates as a variable, and then compare it to the enemies position (Also stored as a variable), then compare the two variables in a condition. Like “EnemyX < PlayerX, and EnemyY < PlayerY, play animation (whatever the animation is)”. Don’t know if that helped but I tried my best : )

1 Like

Hi, did you check the isometric game example? GDevelop 5

if you notice, even in that example the little bat creature following her around doesn’t change his animation.

The core concepts from the various examples all still apply.

If you are not using top down rotation, my best guesses are:

  1. you are going to have to set up events to detect the angle of movement (a lot of math involed)

Or

  1. You instead just have a “position” object that has all of the movement behaviors and events on it instead of your visual sprite. Then you can leave rotation enabled on that object so you can detect its rotation, then have your visual sprite position updated to the position object each frame, then uodate your visual objects animation based off the position object’s rotation.

or you just go with MisterBread009 suggestion:

3 Likes

the position object is actually how I got my player character to have a moving torso. But when I tried it with enemies it got a little wonky. I’m firing up Gdev now to try out Mr. Bread’s
suggestion.

well it’s almost working. The major problem is that the x animations and the y animations are conflicting with each other.
I can have em up/down or left/right but not all four directions.

that doesnt make any sense,
x and y are different things, and cannot conflict.

if you structure your events like i did in the screenshot, there cannot be any conflicts.
i tried this method and it works, even with multible enemys.

ohhhhh!
You screen shot did not load in for me awhile ago.
I will try your method

Your suggestion takes care of my up and down but what about my left and right?

I do cover 4 directions …
If you have trouble understanding coordinates
X < player.x means left of player
Subevent Y > player.y means below player
= leftdown
Y < player.y means above
=left up
X > player.x means right of the player
Subevents for y again
= right down
= right up

No dude, you don’t understand.
It’s Isometric not Topdown.
I can’t “flip horizontally” because it won’t animate properly. I have to have a completely separate animation for my up and down.
So it’s trying to play the animations for my X coordinates at the same time it’s playing the animation for my Y coordinates. Which is causing my animations to conflict.
Thats what I meant by only being able to have left and right or up and down but not both.

I DO understand.
It’s isometric, that’s why it’s angle animations.
Downleft/Downright/upleft/upright.
You only need 2 animations
Face downright
Face upleft
And then you flip your sprites for the other directions

Guess I hadn’t considered that. I really didn’t want to change my animations But that would probably be the easiest way.


you easily can use your 4 animations, if you want.
just change your animations

2 Likes

It isn’t exactly what I had in mind but it will work.
If I wanted their animation to change once they got close to my player character (like swinging a sword or melee) is there a way I could do that without conflicting the animations that are already playing?

use states.
whenever something happens, like distance to enemy <200 (change variable statse of enemy to “walk”)
or enemy is in collusion with swordHitbox (change variable state of enemy to “hurt”)
and so on.

then you use the variable state of enemy to change its animations:

that helps alot thank you!