fix pathfinding for real
This commit is contained in:
+3
-1
@@ -87,6 +87,8 @@ export default class Entity {
|
||||
this.position.set(x, y)
|
||||
}
|
||||
|
||||
// TODO: waypoints go out of bounds
|
||||
// TODO: pathfinding stops if wall is clicked (did you forget to fix the destination?)
|
||||
async takeStep(distanceTraveled = 0) {
|
||||
const speed = (this.speed / (this.game?.tickBudget ?? 1000)) - distanceTraveled
|
||||
const collidables = this.collidables()
|
||||
@@ -100,11 +102,11 @@ export default class Entity {
|
||||
const goal = SATX.vectorToFloat32Array(fixedDest)
|
||||
const nonUniqueWaypoints = this.waypoints().map((w) => SATX.vectorToFloat32Array(w)).concat([start, goal])
|
||||
const waypoints = Pathfind.uniqueWaypoints(nonUniqueWaypoints)
|
||||
|
||||
console.timeEnd('waypoints')
|
||||
console.time('graph')
|
||||
const graph = Pathfind.buildGraph(waypoints, collidables, this.radius)
|
||||
|
||||
// console.log(Pathfind.formatFloat32Array(graph, 5, true))
|
||||
// const tunnels = []
|
||||
// for (let i = 0; i < graph.length; i += 5) {
|
||||
// tunnels.push(SATX.entityTunnel(graph[i], graph[i + 1], graph[i + 2], graph[i + 3], 1))
|
||||
|
||||
Reference in New Issue
Block a user