P
P
prevolley2019-10-17 12:13:39
JavaScript
prevolley, 2019-10-17 12:13:39

How to set the character's trajectory of movement so that he bypasses obstacles?

I'm making a javascript game, a strategy where the character moves by clicking on a point. The problem is that he goes through obstacles, and I don't know how to make him bypass them. Previously, I gave a game with a matrix, where the movements were in squares and set passable and impassable areas. In the case of a vector, I do not know how to do it right. There is an option to create a black and white copy of the map where impassable areas are marked with black, but then again I don’t know how to find a way among them. Please tell me how to set such a movement so that the character goes around impassable areas.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ronald McDonald, 2019-10-17
@Zoominger

This is a typical pathfinding problem. Start with Wiki: https://en.wikipedia.org/wiki/%D0%9F%D0%BE%D0%B8%D...
Google it already, there are a lot of algorithms. Start not with the optimal, but with simple ones, it's easier.

S
Saboteur, 2019-10-17
@saboteur_kiev

Usually this is done - a matrix of objects is created, according to which
A is calculated and the map is drawn independently, more precisely based on your array with objects.
But yes, the calculations for the passage are made not by the picture, but by the "geodata" array

A
Andrew Nodermann, 2019-10-17
@Lucian

Hi
qiao.github.io/PathFinding.js/visual
https://github.com/qiao/PathFinding.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question