New answers tagged

2

Graph-based pathfinding calculates an entire path (multiple turns' worth) and you're using only the first step, throwing away the rest, and recalculating every turn. This is wasteful. Keep following the path already computed until you think you need to recalculate it. If you're far away from the target, recalculate infrequently; if you're near it, ...


0

You don't want to check for a path all at the same time for all of your entities. You could try to set a timer on each of your entities, and poll for a new path when the timer expires (instead of waiting for a move). You can further refine this by only reducing the poll timer when the player changes positions (but this is really dependant on your specific ...


2

Raycasts and steering You'll find the path as you go, casting rays and checking for different cases. Pink - Your entity Red - Offset ray. Cast perpendicular to the forward of your entity. Maintains a specific distance from the wall and used to ensure the wall is still there. Blue - Look ahead ray. Looks ahead for the wall and is responsible for the ...


3

Use the normals of your surfaces to calculate this. Essentially, you're taking your existing edge, and growing it. Then, in some cases, optimizing it to cut out loops or tight corners. For each corner, you get the averaged normal for the two surfaces that make up that corner. For interior corners, since the average would be pointing towards each other, you'...


1

/* Detect nearest enemy */ for (var i = 0; i < nears.length; i++) { /* self.void is an array containing the types of objects I want to avoid */ if (self.avoid.indexOf(nears[i].type) > -1 && nears[i] != self) { var dist = Math_distance(nears[i].x, nears[i].y, self.x, self.y); if (dist > self.avoidRadius) continue; ...


2

To answer the question in the title, any of GM's collision-testing functions will only return one instance, so you need to get creative to retrieve more than one. The best solution I've found (and I use this to ensure that my attacks hit multiple targets if more than one is collided with in a single step) is to disable the collision of instances that you've ...


0

I ended up doing what DMGregory suggested and it works well. Here's some relevant code (though not standalone) that can be used for computing the two styles of tangents. I'm sure this code isn't efficient, and it's probably not even correct in all situations, but it's working for me so far: bool Circle::outer_tangent_to(const Circle & c2, ...


1

I'm not sure about what you're trying to achieve, but I can help with your starting question: how to get the ids of nearby instances, given an object_index to look for. The idea behind is: given a radius r (in your case, 100 pixels), there may be more than one instance which is distant less than r from a reference object. So, we have two properties to find ...



Top 50 recent answers are included