0 votes

Hi All!

I'm trying to use 3d path finding with navmesh tiles and gridmaps.

In my mesh library i have plane tiles, each of which is a mesh instance (plane) with navigationMeshInstance as its child.

In the main scene, the tree is:
Root node
-- Navigation

This works for nodes which move along paths towards targets whose global transforms are set in code.

BUT, the player node is to move along a path from whatever its position towards a clicked point (point and click movement).

I'm using this function to return the target point for the player node:

func raycast_from_mouse(mouse_position, collision_mask):
    var ray_start = camera.project_ray_origin(mouse_position)
    var ray_end = ray_start + camera.project_ray_normal(mouse_position) * ray_length
    var space_state = get_world().direct_space_state
    return space_state.intersect_ray(ray_start, ray_end, [], collision_mask)

I then set the collision mask in a separate function which returns a 'collider' point towards which to move.

This method works great for baked navmeshes but the raycast doesn't seem to be colliding with meshlib tiles... Anyone know why?

in Engine by (396 points)

Right, solved. Found the answer in the docs. The intersect_ray method only collides with bodies, which I managed to overlook. My tiles were just meshes with collision shapes... There I go.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.