How do I make an enemy move and attack? [platformer game]

Get help using Construct 2

Post » Sat Jan 31, 2015 9:56 pm

Hello everyone,

Edit 01/02/2015 01:28: This is Travis Caven (this part is in case people such as teachers, moderators think I took the game from someone else, notice my game appeared on first page of Google)

This game is for a school project with only about one week to finish it.
I have looked this up on Google but nothing seems to help. Most of the forums either have information I don't understand or they have uploaded files which don't even work anymore due to them being deleted.

What I want is to make the skeleton enemy do a patrol between two points but when it detects me I want it to follow me and attack. I have done this method with using two invisible boxes as collision points for the skeleton to walk through but have no idea how to do the rest. My game is being based off a Castlevania game so this is the reason for these enemy patterns.

Been doing this for about 10 hours now and I still can't find a way to get this to work. I have attached a capx file to this post so people can have a look. I do have other levels and stuff like that but I have only attached the Hallway layout to make it less confusing with what I am stuck with.

Sorry if this was already answered somewhere on the website.

Thanks in advance for help people can give me.
You do not have the required permissions to view the files attached to this post.
Last edited by DagothUr on Sun Feb 01, 2015 1:29 am, edited 1 time in total.
B
4
Posts: 8
Reputation: 218

Post » Sat Jan 31, 2015 11:28 pm

@DagothUr
Hey check the capx out. All I did was add a distance check between your player and skeleton. Then if its less then 200 he will start following your guy. You can change the 200 to be more depending on his 'eyesight'
Then I added a boolean to the skeleton to determine whether he saw the player and to start following him. If he's currently following the player he will ignore the collision checks on the invisible boxes. Let me know if you have any questions.
You could also add an else under the distance event so he stops following the player if you are more then 200 away.
You do not have the required permissions to view the files attached to this post.
B
33
S
8
G
2
Posts: 100
Reputation: 2,635

Post » Sun Feb 01, 2015 12:37 am

@thatserafimkid
Thank you so much for the help.
I don't think I could have worked this out. But I know what to do in the future now for making enemies move around and follow the player. Thanks for going through the description of the changes you done.

When I make him attack it would be done in a similar way wouldn't it? I remember reading one other persons question where they said they told the enemy to walk towards the player until they were at a certain distance (I think his example was 35 pixels) then the enemy will attack.
B
4
Posts: 8
Reputation: 218

Post » Sun Feb 01, 2015 1:06 am

@DagothUr
Yes excactly. Just copy the distance code and make it smaller instead of 200 away. Make it whatever fits your animation.
You're welcome.
B
33
S
8
G
2
Posts: 100
Reputation: 2,635


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests