I am working on an Isometric ship horde game, and I ran into a snag I just cant seem to fix or find info on.
What I want the enemy ship to do is change the animation so it will face the player depending on where the player is around the enemy. This seemed like a no-brainer, but here in Gdev I cant figure it out.
I have tried these two methods, but I either have it wrong, or it isnt working how I would like it to.
With this first method, It doesnt seem to change the enemy anim at all.
With the second, I got lost in the basic direct North, South, East, and West facing animations, but the diagonals work just fine. I think it needs a second condition for each event, but idk what that would be.
Any help would be great!
By default all conditions in event needs to be satisfied so putting IF all of these are true makes no sense
BUT also can cause problems so better don’t do that
And i have exactly what you are trying to achieve here
1st of all print to text object angle of enemy to player or at least angle of cursor to enemy to see at what angle what value shows
Trust me it really saves a lot of frustration
Just off the top of my head, I would put an invisible box around each enemy and have it rotate towards the player.
Depending on the invisible box’s angle, you can have their animation change depending on that. You could try that, not sure if that will affect performance, but it could just be a 5 x 5 box or something.
So far I have this:
And the Angle is first called in that top condition like this:
Its still not quite there. No enemy animation changes.
Also, Im not sure what you mean here:
“1st of all print to text object angle of enemy to player or at least angle of cursor to enemy to see at what angle what value shows
Trust me it really saves a lot of frustration”
I thought that is what my first condition did, but I must be off.
Sorry then by print i mean create text object and place it on scene so you can see it
Then you set in action WITHOUT CONDITION that text object to ObjectName.Angle()
And now you will see what that object angle have
Same as in my example above you can see in preview that in upper right corner under crosshair button angle cursor to player
This way i was able to see at what angle what value is shown and use that to determine my player animations
Ok super! Got that angle text going. Now, for some reason, the enemy ship still wont change anim when we hit a particular angle. The last image shows what I did, but the angles are different of course. Am I missing something there?
Take this into your heart
NEVER EVER try to make something from beginning to end before you test it
What i mean by that you do not make whole animation change routine and expect it to work
You do it piece by piece
If 1 part works you move to getting another part to work and so go on
1st thing you should try is to check if rotating ship alone changes between two animations
Remove condition to check if ship angle is toward another ship and just make so if ship angle is something it should change animation for example between top left and bottom left
And you rotate your ship manually by for example keys
If that works you move to adding another animation change on some angle and check if 3 of them change properly
After you get all of them to work based on angle NOW you add some condition to it like check if ship angle is toward another ship
Another thing look at my screenshot
You see i have one event with if one of these conditions is true which inside of it have two if all of these conditions are true
That is due at exactly left (angle of something is pointing exactly left)
Which is either 180 or -180 (180 is from left going up and -180 is from left going down)
It is not a bug but well actual logic where 180 is higher than -180 so it won’t work by default and you need that trick to get it to work
But that depends do you even have angle that cross that animation
So like if you have animation that goes for example from bottom left to top left then you need it
But if you have like animation check at left to top left and another animation at left to bottom left then you don’t need it
So start checking angles and getting them to work 1 by 1
Ok I see what you are saying. Thanks for the advice, that makes total sense.
Ill try some experimenting and post when Im done. Or stuck. But hopefully that wont happen.