Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,390

Leadwerks Game Engine 5 Beta Updated with Pathfinding, Bone Attachments, and more...


Josh

11,631 views

 Share

A new update is available for beta testers. This adds navmesh pathfinding, bone attachments, and the beginning of the Lua debugging capabilities.New commands for creating navigation meshes for AI pathfinding are included.

NavMesh Pathfinding

In Leadwerks Game Engine 5 you can create your own navmeshes and AI agents, with all your own parameters for player height, step height, walkable slope, etc.:

shared_ptr<NavMesh> CreateNavMesh(shared_ptr<World> world, const float width, const float height, const float depth, const int tilesx, const int tilesz, const float agentradius = 0.4, const float agentheight = 1.8, const float agentstepheight = 0.501, const float maxslope = 45.01f);

You can create AI agents yourself now:

shared_ptr<NavAgent> CreateNavAgent(shared_ptr<NavMesh> navmesh, const float radius, const float height, const UpdateFlags updateflags)

Here are some of the NavAgent methods you can use:

void NavAgent::SetPosition(const float x, const float y, const float z);
void NavAgent::SetRotation(const float angle);
bool NavAgent::Navigate(const float x, const float y, const float z);

New capabilities let you find a random point on the navmesh, or test to see if a point lies on a navmesh. As @reepblue pointed out, in addition to AI this feature could be used to test if a player is able to teleport to a position with VR locomotion:

bool NavMesh::FindRandomPoint(Vec3& point)
bool NavMesh::IntersectsPoint(const Vec3& point)

You can call Entity::Attach(agent) to attach an entity to an agent so it follows it around.

You can even create multiple navmeshes for different sized characters. In the video below, I created one navmesh for the little goblins, and another one with different parameters for the big guy. I created agents for each character on the appropriate sized navmesh, and then I created a big AI agent on both navmeshes. On the navmesh with big parameters, I use the regular navigation system, but the big agent on the little navmesh gets manually repositioned each frame. This results in an agent the little goblins walk around, and the end result is mixing of the two character sizes.

The current implementation is static-only and will be built at the time of creation. You need to call Entity::SetNavigationMode(true) on any entities you want to contribute to the navmesh. Physics shape geometry will be used for navigation, not visible mesh geometry. I plan to add support for dynamic navmeshes that rebuild as the level changes next.

Note that by default there is no interaction between physics and navigation. If you want AI agents to be collidable with the physics system, you need to create a physics object and position that as the agents move. This gives you complete control over the whole system.

Bone Attachments

To improve speed bones are a special type of object in Leadwerks Game Engine 5, and are an entity. Bone attachments allow you to "parent" an entity to a bone, so you can do things like place a sword in a character's hand. You can read more about bone attachments here:

Lua Debugging in Visual Studio Code

The beginnings of our Lua debugging system are taking shape. You can now launch your game directly from VSCode. To do this, open the project folder in VSCode. Install the "Lua Debugger" extension from DevCat. Press F5 and the game should start running. See the .vscode/launch.json file for more details.

  • Like 4
  • Thanks 1
 Share

5 Comments


Recommended Comments

Wow.  This is a huge improvement over the current system.  Make it dynamic and it'll be perfect.  ?

I'm not clear on how finding points on the navmesh works.  How do you do a pick on the navmesh?  Or does IntersectsPoint check a radius around the point and return the nearest one?  If so, how do you change that radius?

Link to comment
3 hours ago, gamecreator said:

Wow.  This is a huge improvement over the current system.  Make it dynamic and it'll be perfect.  ?

I'm not clear on how finding points on the navmesh works.  How do you do a pick on the navmesh?  Or does IntersectsPoint check a radius around the point and return the nearest one?  If so, how do you change that radius?

In this example I am doing a regular camera pick and then checking to see if that point lies on the navmesh. I do not have the radius value exposed because I didn't see a point to that, but if you want I will add that in as an optional parameter.

Link to comment

No need if you think that'll always catch the navmesh because the navmesh isn't always flush with the ground.  Sometimes it's a bit above, sometimes it's below the ground.

Also, does the system have a way to find the nearest navmesh point, if your pick doesn't return a navmesh?  Or do you have to kind of search it out (which isn't too difficult)?

Link to comment

It actually accepts separate values for all three axes. I am using zero for X and Z and 0.35 for the height, which seems to work, but I will add a radius parameter for XZ and an optional height parameter.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...