Boundary system (navigation system) in BGE

Hi folks!

This week I spent most of my time creating a boundary system in BGE. And now I’m looking forward to sharing it …

A small animation showing the system working: http://www.youtube.com/watch?v=P108MdGliyM

And check the blend file attached … (just open and press “P”)

How it works:

Setting the boundary:
1) I have two boundaries per object, the Inside boundary and the Outside.
2) The two boundaries are nominated following the rule: “Boundary_” + obj.name + “_I”(or “O") - (e.g. “Boundary_Suzanne_I”)
3) The boundaries are Collision enabled and have the property: "B
” + obj.name (e.g. “B_Suzanne”)

Setting the object:
1) Create an Always sensor, link it to the script boundary.py and link it to a movement Actuator called “MOVE”
2) Make sure the center of the object is in the center
3) Add the objects through an AddObject Actuator (that way they all have the same name) :slight_smile:

Now you can setup your own boundary using the script the way it is. If you need extra customization, please feel free to share the results here :slight_smile:

Problems you may have:

  1. If you are parenting the boundaries to another object (e.g. the visible fake boundary in the example file), remember to apply the scale in the parent or else odd things will happen - BUG REPORT.
    2)Elif :smiley: the outer boundary is not tight with the inner boundary, depending on your pulse set to the sensor, the rayCast will hit the “outer face of the inner boundary”. Right now, in BGE, is not possible to check the normal of the face we are hitting (or atleast in a fast/cheap way). Therefore we have these two boundary objects, and they should be very tight.

Problems I have :o :
I’m using multiple boundaries. For each object I have a different boundary. As the rayCast function doesn’t have an X-Ray mode yet (BUG REPORT) the rayCast returns None when the boundaries of other objects are hit, even if the object is inside its real boundary.

 If you think this .Blend file will be useful for you, please copy this message below and post it as a commentary:
" DEAR BLENDER GAME ENGINE DEVELOPERS (Benoit, Campbell, and others) I love your work, and I'm very happy with all the current features available in BGE. BUT please code an x-ray mode to the rayCast function (or make it the default, as I still can't see why it is different :p ). :D:):D:):D:) "

As a matter of fact, I can see a way to solve this. I need only to set different height levels for different objects, and the RayCast fromPos and toPos parameters will follow. This is however, a hack, and does not solve the other problems I’m having with rayCast :slight_smile:

Forewords:

  • To run it properly you need the latest BlenderSVN (to use Mathutils). You can download it from Graphicall.org

  • Thanks to Campbell (ideasman) for the support and the sheepNav.py file, and the Apricot team and developers for the incredible work. And a big thank you to all who supports Blender and Apricot (buying DVDs, reporting bugs, coding, …).

Attachments

boundary_BA_01.blend (227 KB)

Sweet, how did you do the trails in your youtube video? :smiley: I am guessing it’s the motion blur 2d filter?

Hey thats nice! Good Job!

Terry

It is really nice. I was waiting for VIMEO accept my video to talk about that.

Test 01 - http://www.vimeo.com/1492170
Test 02 - http://www.vimeo.com/1492070

This tracking was made using the motion blur 2d filter with a very high value (0.997 I think).
The idea comes from … you, hehhe

Thanks Mike :slight_smile:

Thanks Terry.
I’m still working on it. When my object go inside the inner boundary something it doesn’t return back. (in the video you can see some of them).

I coded a following ground script that probably will be integrated with the boundary.

The file is attached, press “P”.

Also there is a cool think I would like to share:

How to syncronize dRot and Time Delay:

dRot = ang * 1.2 / (time * LogicTick)

for 60LT:
    dRot = ang * 0.02 / time

That way you can set the amount of rotation (in angles) you want the object to have in some time (in pulses).
This create a kind of offset. The object is always aligned with the ground that was hit in the last pulse. It’s not a problem for me, and that way I have a smooth transition …
(so far I was trying to follow the ground that way - http://blenderartists.org/forum/showthread.php?p=1184289)

Attached there is a test with different delay pulse values and the value in the script (rotX = angle * 0.02 / deltaTime).

Attachments

BA_Following_Ground.blend (240 KB)


Im sure this dosnt give the same level of control but heres a version that works with just 2 logic bricks, no python. (only with latest svn)
You should be able to adjust the settings through python to have some control at least.
http://members.optus.net/~cjbarton/BA_Following_Ground_NoPy.blend

I tested here and the performance is a little worse.

And check the path, is not so smooth:
http://img379.imageshack.us/img379/4205/ssbk3yj7.jpg

Maybe it is because the ray is not always vertical (since we are rotating the object? ).
Hm a good option would be to set the ray direction locally (considering the orientation of the object) or globally (as a global z ray as I’m using in the script).

Thanks Campbell (and thank Benoit ;))