Learn to use the steering actuator and create a navigation mesh which will let the object path find around the level instead of running into a wall.
Thanks John, that helps a little. But how can you get an enemy to patrol? I tried moving the target to an inactive layer, then spawning it in different locations. But the enemy will track to it even if it’s on a different layer. And I can’t seem to select two or more targets so the enemy can track to the closest.
I can see where the update might come in handy. It stops the enemy from moving straight to the target. I’ll have to experiment with that.
EDIT: Nevermind, I see how to it. Keep the target on the main layer, move it with python to different areas for patrol. And when the enemy sees the player, move the target to player and parent it.
Yes pretty much what i was going to say to do as well and with python you can dynamically change what objects it tracks to as well.
I would use states. So the sensors not being used will be shut off. EX: State 1 = Enemy is on patrol, steers toward a target randomly being moved by a script, when enemy collides with the target. (With BPR’s help, I have such a script. Would you like me to post it here? Or start another thread?) with a empty with a ray for enemy eyes, if the ray saw the player, it would change the player to state 2 = steer towards player, instead of target. Experimenting with it now. Thanks to you I finally got the navmesh working.
Do you know how to make it steer to the nearest property? Like you have 4 cover points with property ‘cover’, and the object steers to the nearest one. ThaTimst3r made a series of videos on this but I can’t get it to work… :no:
EDIT: Yay, I did it! I used the script on this thread: https://blenderartists.org/forum/showthread.php?233323-Python-Track-To-and-Steering-Track-to-selection
yeah just like what Nemescraft sayd , i want to make it steer randomly to the nearest prop, how ca wee do that
So do you want to steer it to a random property or to the closest property?
If you want the closest one, I’ll put a blend file up in a sec…
Here it is:
EnemyAI.blend (644 KB)
cool man this is great