[Solved] Problems related to enemy ranged attacks

Hi there…

I have a problem with my enemy attack , i know this is also related to the events i made, and I don’t know how to solve it

So what i want is…when the character faces an enemy and enemy attack character with ranged attack, the ranged attack will not return to the character when character is on otherside of enemy.

The point is i want the enemy attack not returning and just going to the first time its shot.

Reversed

Try Switching positions of your events add force and crate object. The object needs to be created first so that GD knows to what object the force is applied to.

where should I change the event?

Just drag the event add force under the create object. Stay in the same event window

Like this?? Idk…

this should work too, but you do not need to make it a subevent. it can be in the same event window, just in the last position.

still the same … as before, I also remove from the sub event, then add trigger once both are the same.

can you upload your json file?
it has to do with your event structure.
if your repeat for each is moved away from the mainevent, that is not trigger once, it should work.

Okay… Check your message

Just to explain to you what I see if happening, and why slash is asking you to move the action:

Each event has columns: The conditions and actions.
When every you reference an object in a condition it becomes “selected” for all matching objects. This selection is inherited by sub conditions as well.
Actions that reference objects are applied to all “selected” objects of that type. When you create a new object it becomes selected only for that current action (not sub events).

So in your case you are not referencing EnemyBasicAttack objects in any of your conditions, so when you preform an action on EnemyBasicAttack it assumes you want to apply that action to ALL EnemyBasicAttacks.
So you can either add a condition that references the newly created object (typically by setting and referring to a unique instance variable value) OR more simply move the action on EnemyBasicAttack to the action block where you created the object (and where it will be automatically “selected”).

I hope that helps explain better how it all works (at least from my experience as a user)

1 Like

The problem is, that the condition if frame = 2 doesnt seem to always trigger.
i changed your plant to 3 animations, where the second animation ends with the attack, and the last animation is the cooldown.
this way the engine has all the time to check if animation is finished, instead of if framenumber is …


you can ignore the color event, i just did that to always see when the attacks overlapping.

tested it a couple of times an did not see any attack skips.

2 Likes

Ohhh its nice… Thanks for your efforts…

i need to learn from slash. using gdevelop and sir. you problem solving skills are crazy!