Yuka Game AI + Babylon.js Examples - the 1st Release

NICELY done !!!

2 Likes

So cool! But how do you pick good values for the spatial indexing?

Cool buddy! :wink:

2 Likes

The babylon examples page is down right now @labris

Thanks, seems it works for me at the moment - Yuka | Examples with Babylon.js

1 Like

weird I just stay pending on this request but will try when home :slight_smile: have seen weird network things here before

Not sure if this is the correct thread to ask, but does Yuka have some documentation other than the API?

I’m looking for a step-by-step on how to get some basic things going and explanations of what things do, like the BabylonJS documentation has for the recast plugin:
https://doc.babylonjs.com/features/featuresDeepDive/crowdNavigation

I’d like to try and play around with Yuka, but I’m pretty new to these things. The link above provides some simple code examples I can quickly change some parameters of and see what they do, and adds some complexity with each next step.

Yuka itself is mainly based on the brilliant book “Programming Game AI by Example” by Mat Backlund (but uses Javascript instead of C++).
This book stands out from the pack by providing industrial-strength solutions to difficult problems, like steering and goal-oriented behavior. Mat guides the reader toward building a foundation robust enough for real games. This book is a must-have for anyone new to the field, and has tips for the seasoned professional as well.

Here is the link - Programming Game AI by Example.pdf - Google Drive

“Using easy-to-follow and well-described examples, this book shows you how to use most of the techniques professional AI programmers use. A great introduction for the beginner and an excellent reference for the more experienced!”
— Eric Martel, AI programmer, Ubisoft, Far Cry

3 Likes

Thank you! That’s a great starting point. Is the best place to ask questions about Yuka the discord by the way?

@censor

When I was programming the examples for BabylonJS with YUKA I found the API very selfexplaining and easy to understand. I bet you will easily follow the examples code and understand how things are working in majority of the cases.

I think, @labris will agree as well :wink:

2 Likes

Hi Yuka fans.
Im just starting to play with Yuka and wondering how to set a loaded GLB as a Yuka entity. I’m using this example as my base and loading a glb into it via asset container, duplicating it, and surrounding it with a bounding box.

Ideally, I’d set the bounding box as the Yuka entity - but that doesn’t seem to work (and the caution around using TransformNodes doesn’t apply, right, since it’s just a box mesh?).

See lines 145 - 160. Three cases there - only the one that pops the asset out of its bounding box works (but posrotscale is then tweaked - and i’m not sure how i would programmatically know what to select in any case in a complex mesh). Ideas?

@oriongu thought you might know offhand?

-----update----
Instead of trying to attach the loaded GLB itself as target, i am creating a separate target mesh (simple box) and then setting its location to the location of the GLB in registerBeforeRender. that’s seeming to work pretty well.

Hey @bigrig glad you got it solved, so you know I only use YUKA for the navmesh part which it does very well, the rest was a bit too complicated for me at the time I started. You should be teaching me :slight_smile:

  1. What is the optimisation like?
  2. Are you using workers?

Thanks

This seems reasonable :slight_smile:

Hey @labris thx. Quick question: i’m trying to replicate some of your examples in a PG. I’ve got almost a direct copy of your pursue example in this PG:

For some reason, every time you click play in the PG, it’ll start the vehicles further and further out into space. A hard refresh recovers it. And if you increase a variable like maxSpeed it’ll start even further out into space.

Any idea why?

-ben

I think it is because of some window things in PG. Some values, like time, are not nulled with soft reload. If you download your example from PG and open it, it works fine.

1 Like

@bigrig Yes, that could be the case. I saw that you’re logging into the console a lot of positions. I’ve created a little debug helper for myself and shared it here: Console3 - logging to the rendering canvas

This is how it can be applied to your PG:

1 Like

Nice, that’s really helpful.
Here’s a PG with your debugger on - and with the pursuer chasing around a character, where the evader target gets attached to the character position - and where you can set the behavior to: seek, pursue, or pointAt


(red sphere on head is the target. poor little guy)

(one thing that’s odd is that the pursuer and evader meshes disappear fairly often, especially in pursue. maybe some yuka oddity in setRenderComponent?) (also, as per thread above, you have to do a hard refresh on pursue (only in PG env), or the evader will be way out in space)

next challenge: turn pursuers into NPCs and figuring out how to have the NPC pursuers respect collisions.

Seems that evader behaves a bit strange, probably it should be somewhere near the model position?

Yea, for pursue, the evader starts way out in space before it eventually makes it’s way back to the player… and then all is good. Something weird with initializing. Maybe this is related? If you set the position of an entity to anything other than 0,0,0, it’s pivot point doesn’t seem to change.

Here’s a PG for the simple “rotateTo” case, where the Xpos of the Pursuer is set to 1 (line 305)

Seems like the pivot point is stuck at 0,0,0. Resetting the pivot point explicitly doesn’t work also. I thought that bakeCurrentTransformIntoVertices would lock in whatever you’ve done to the mesh prior, yes?

What’s the trick to position/rotate a mesh before giving it to Yuka?