Mugen87 / yuka

JavaScript library for developing Game AI.

Home Page:https://mugen87.github.io/yuka/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when using NavMesh

Coder2012 opened this issue · comments

I am trying to use code from the first person example, I have successfully loaded my model and then loaded my NavMesh. I set this successfully on the entity. I see my model fine and can see the NavMesh on the floor thanks to the NavMeshHelper.

The issue is that when I update the controls in the animate function I get this error:

Uncaught Error: YUKA.NavMesh.clampMovement(): No current region available.

If I comment this line, then I see the scene again, I can rotate but cannot move around with the arrow keys. The example is on my github if you manage any time to look at the problem.

https://github.com/Coder2012/3d-game-vue

I've tested your application on my computer however I'm unable to reproduce the error message. Instead I see some deprecation warnings from three.js and this Yuka related warning:

YUKA.Player: Unable to use Pointer Lock API.

That happens because you have a minor issue in the usage of FirstPersonControls. The connect() method must be called after a user interaction. Similar to the official example, this is normally done after the user clicks at some sort of UI element. It's not possible to call this method in an onLoad() callback (which is a restriction of the underlying Pointer Lock API).

So I suggest you implement a "Start" button or an overlay like in the demo that allows you to use an event listener for calling connect().

Ah this makes sense now, I was thinking why you were using an eventListener for someone to click on the controls. I noticed it takes the cursor away from the user, this must be why you have to get it from a user interaction, similar to how fullscreen API works.

Thank you!

I've implemented the event listener to remove the warning, however I just cannot understand why I'm getting the original error above. Any tips on how to debug this?

Actually I was passing time to controls.update(time) instead of delta, silly mistake.

Danke schön