Drawing a path to traverse Character

Hi Everyone, iam working on character movements.When clicks on particular position on the ground then I would like to draw a path from character current position to clicked position and character should be move in the drawn path only.And path should become invisible as character moves along with the path.

Path should be generate as shown in the below playground but path should be generate without any sphere.

https://playground.babylonjs.com/#3KUQ1L#18

Note:
The Main Challenges are:
1.Path Generation From Character position to clicked position (Usually clicks on ground).

2.Path should not pass through any meshes
i.e. Path should not intersect any meshes in scene

3.Path should become invisible as character moves along with it.

1 Like

hey that is nice challenge but i dont have time this for week :frowning:

Ok @nasimiasl Thanks

First you need an algorithm for pathfinding:

  • The gray one are the opponents (this are the walls on this site)
  • The green one is your character which you want to move
  • The red one is the target position

image

The path is calculated a bit edgy but you can use the spline interpolation to get a smooth path.

Thank You @Necips

Next you need is a shader to draw lines on a mesh

1 Like

It’s a great idea @Necips , Thank you very much.

2 Likes