|
0 registered members (),
16,302
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Avoiding object while walking to player
[Re: raiden]
#172289
12/15/07 02:34
12/15/07 02:34
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
Expert
|
Expert
Joined: Feb 2006
Posts: 2,185
|
Quote:
Hi Lukas 
I got you fixed up bro, I couldn't resist the challenge of writing this and it works really well.
Code:
insert raiden's awesome code here
I hope I explained everything ok in the comments, also the 100 passed as a parameter in traceAngle is the distance of tracing, so you can change that if you like. The code traces in 2 directions from the enemy and the angle is 25 degrees(which can also be changed in the define above)to the left and right of its x pos. When a distance is returned it sets the state and forces the turn vector(face_turn) to be the diffence of the new direction instead of the players position. Then the enemy turns to avoid the obstacle and once the trace is in the clear, its sets the state back to normal and begins tracing for new obstacles.
I know its a little backwards on the turning, you asked for a turn direction in the opposite, but I think this works pretty well.
Check out this demo to see it in action: Test Enemy Obstacle Avoidance
You'll see the enemy head towards the player to which you can't see, but watch how the enemy turns to go around the block in the middle.
I hope that helps you out bro. 
-raiden
dude, i hate you i wish i would've known how to add that to my ai, except with them strafing around it rather than turning
i'm gonna have to kill you, then hire you for Manga Page lol 
Last edited by mpdeveloper_B; 12/15/07 02:36.
- aka Manslayer101
|
|
|
|
|
|