Jump to content

enemy movement


cassius
 Share

Recommended Posts

In my third person game there are several sword fights.In every case if the player disengages and walks off the enemy remain static.Sometimes I need the enemy character to run after the player and re confront him. How could this be coded?

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

  • 2 weeks later...

It could just be as simple as a distance check from the enemy to the player (depending on your game level design) and also how soon the enemy starts pursuing the player - so you may not need to worry too much about the pathfinding.

 

It's just a case of logic really - you may have a set value that is basically a critical distance check so, if the player has exeeded the set distance, then the enemy assumes the player is fleeing and will then home in on the player - when they are within a set distance you can them deem the enemy to be confronting the player - the easiest way being to just assume the player is going to turn and face the enemy based on the enemy being so close- other than that you'll have to overtake the player based on the direction they are heading in and then have your enemy turn and face the player when he has overtaken the player (could get messy though, if the player is not interested in the confrontation and is just changing direction to shake off the enemy), so you could just force the player to slow down as though the enemy has grabbed them - again, this is purely done on a distance check (or collision check if you want) - then you deactivate the 'grab' on the player to allow both player and enemy to have a scrap (or to allow the player to try and flee again).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...