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

0 favourites
  • 4 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • 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.

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)