I have been pulling my hair out trying to figure out how to get some basic enemy AI going.
I would gladly use python but I can’t find any good tutorials on getting it working with blender. I don’t have the time to learn Python itself. I barely get enough free time to use Blender itself. I just want to learn how to do scripting in blender. According to the blender python scripting tutorials I did find, I pretty much have to be a python god to do the tutorial.
Anyway…
I can’t use just rays because they can’t cover an area.
I can’t use just collision boxes because they can see right through walls.
I am trying to mix collision and rays using a very basic setup:
0. Enemy object spins around.
Collision box parented to enemy object collides with player.
Object tracks to player.
If a ray hits the player without colliding with a box or anything, the enemy is deleted via “end object”.
3.5. If a ray doesn’t hit the player within 3 seconds, the enemy box forgets the player for almost 2 seconds and then repeats the process.
Unfortunately, I attempted to test this and I can’t even get the collision box to detect the player.
Something’s wrong.
Can you guys take a look at the blend and help me out?
The arguments of the function are:
-object: The object doing the looking
-target: the target getting looked at
-target_width: the width of the target
-ray_dist: how far the object doing the looking can see
-ray_prop: only detect ray collisions with this property
-primary and secondary: view fields, allows for peripheral vision. Its how wide the object doing the looking can see. The angles are halved, so 90 = 180. In the instance of primary = 80 and secondary = 90 (defualt), the agent has a sight cone of 180 degrees.
A 0 returned means the target can’t be seen. 1 means the target is in its primary view field and 2 means the target is in its secondary view field.