Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / enemy running away from player

Author
Message
Dark Master Ev
16
Years of Service
User Offline
Joined: 18th Nov 2008
Location: That is a very good question...
Posted: 17th Jan 2009 06:01
I'm making a small police car chase game where the enemy runs away while avoiding obstacles.
any help would be nice.
thanks
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 17th Jan 2009 12:52
Well, have you tried coding any of it yourself? We can't just write it for you, otherwise we'd be the ones having all the fun!

If there's a particular problem that you have with anything, after trying, let us know. Good luck!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 17th Jan 2009 21:29 Edited at: 17th Jan 2009 21:30
To get the enemy to run away from the car, find the angle between the enemy and the car, then add 180 degrees to that angle, set the enemy to that angle, and move him forward. Not the most realistic method but it should do. To get him to avoid obstacles you could probably do some basic A* pathfinding -- Google it -- but the easiest way would be to check if there are any obstacles in front of the enemy, and if there are, turn him right or left, and keep turning him while moving until there are no longer any obstacles in his path for a short distance. Once again this won't look all that great but should probably do for a simple game. At least make an attempt at these, and if you have any trouble then I can post a little code snippet.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 17th Jan 2009 21:32
I did something similar to what AndrewT sugguested here

Runaway Cubes!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 17th Jan 2009 21:40 Edited at: 17th Jan 2009 22:18
Hmm...I guess if Sixty Squares posted his code I'll post a little snippet:



That code doesn't handle obstacles yet. I'm doing that right now.

EDIT:

Here's a little snippet which shows a red ball dodging obstacles:



Dark Master Ev
16
Years of Service
User Offline
Joined: 18th Nov 2008
Location: That is a very good question...
Posted: 19th Jan 2009 16:36
Thanks for your help these codes will really help. oh by the way next time I'll post the code I've tried
Dark Master Ev
16
Years of Service
User Offline
Joined: 18th Nov 2008
Location: That is a very good question...
Posted: 28th Jan 2009 02:18
I thought i should post on this on my previous post:
so... i tryed combining both of AndrewT's codes to make the enemy run away from the player and it worked... sort of the police car won't show up unless i chantg the object number to an already used one so can someone please help

Sorrey if i don't do the code box right

heres the code:

Login to post a reply

Server time is: 2024-11-24 15:02:07
Your offset time is: 2024-11-24 15:02:07