Need help with enemy

Ok i am making a game and i have a play able character and the play can shoot bullets but here is where i have problem.
I want to make the enemy go left and right and when the enemy is moving the animation is run but i have a casted a ray from the center of my enemy and when the player is in range of 40 pixels the enemy changes his animation to attack. And this where the problem start. See when the enemy is coming from the right every works but the enemy stops and the attack animation keeps on happening but i believe i can fix it the main issue is when the enemy is coming from left side the attack animation doesn’t complete the enemy keeps moving in the first frame of attack animation pose.
If anyone can help pls try to code the whole thing and send me a picture. I am new at this so don’t understand development language but if you are unable to send me a picture just help by texting thanks

Can you provide screen shots of your events so we understand how to fix the issue.

2 Likes

Hey ummmm… Because of the problem i deleted the old script and rage quit but the next day i posted this Post and you replied so i made a new script and now i am having 2 problems.

  1. I made it so when the enemy collides with goRight or goLeft the enemy will be flipped yes or no so when i preview it flips but teleports a bit forward.

  2. When the attack animation plays the enemy gets inside of the ground and it continues the animation even if the player is not near. And i have updated the posts so you should find a image.

That sounds like it could be an issue with the centre of the sprite image. Edit the points of the sprite, and move the centre to the middle of the image.

For example, as the green arrow indicates:


Check the collision box of the attack animation. It may be that it’s smaller than the sprite attack image.


Where do you stop the attack animation? And have you got the attack animation set on Looping?

2 Likes

Yeah the animation is looped and if the player is not near the enemy and the attack animation triggered then the attack animation will finish and then back on Run animal and enemy will go back and forth.

1 Like

Can you screen snip the events that you just described?

2 Likes

No i haven’t scripted it yet i want this to happen. And also the problems is still there because everything was the same i have updated the posts so you can see

1 Like

Wait, you’ve described a problem with events that don’t exist? I’m confused. How can you say “if the player is not near the enemy and the attack animation triggered then the attack animation will finish” if you haven’t got events for it?

The photo? There are no events to set the animation to anything else once the Attack animation starts.

2 Likes

I screen short the events i will delete the events ss because new users can only put one image at one posts

1 Like

I think it’s one image per post. So you should be able to add a new image in each new post.

2 Likes

I edited the image. Now it’s 3 in one so you should be able to see it

1 Like

Any help? Maybe? I can’t move forward from here if this is not solved

1 Like

some here i quit beacuse of this problem

1 Like

Like I wrote, you need to add events that change the animation from attack to something else. You’ll have to decide what the conditions are that change it - maybe don’t loop the attack, check if the animation has finished playing and change animation to something else.

1 Like

I have tried but it doesn’t work

Condition:The Animation of enemy_2 is finished

Action:set animation of enemy_2 to Run

I did that but it didn’t work at all

Can you screen shot the new events and confirm looping is unchecked for the attack animation?

1 Like

I am very sorry i forgot to uncheck looping. Now it works but i still have the second problem you can see i hace updated the image.and thank you so very much for helping just a bit more help whould be appreciated thank you again

Check that the collision box for the animation - not the one you added to the top right, but the one in the game image - is the full image.

1 Like

Yeah the image collision box is too big but i don’t know how to reduce it i downloaded a SpriteSheet from itch.io btw i have updated the image. And do you know how to change the image coalition box??

When editing the sprite, click on “Edit collision masks” button in the bottom left, and then click on the “Use a custom collision mask” button. You can click and drag the corners, and add new corners.

1 Like