I’m looking back at the LD53 jam and the biggest issue people had was the follower pathfinding.
I’m doing some testing and it looks like the Move fails when my player is next to the impassable wall.
My guess is that the location where the centre of the player is, is a location that the follower wouldn’t fit without being embedded into the wall, as the player is thinner than the follower.
What could be a good method for getting a “nearest location” for the pathfinding to navigate to if a location is “good enough” instead of exactly at the precise pixel location?
What does your game look like. If you could post a pic of the game or something playable it would help.
I love the pathfinder but that’s something that bothers me. I have several untested ideas that might fit. I can expand on any.
Idea: use a hidden copy of the player. On mouse release, change it’s position to the cursor x,y and use the separate objects to push it away from the wall. You could then use the pathfinder to move to the copy’s position.
Downside: The separate action picks the closest edge and could put the copied object on the other side of a wall and the x,y would still be unreachable. Fix: It depends on the game. If the viewable side of hitbox is smaller than the unreachable side then the separate action would always choose the reachable side.
Idea: If a wall is touched/clicked use it’s angle or an object variable to calculate a point far enough away from the wall. This could be combined with the previous idea or with a ray cast. More on this if needed.
Downside: corners, irregular shapes and angles. Fixable.
Idea: If it’s an object other than a wall then it could have a preset location to go to saved in object variables. IDK your game. If it had a desk, clicking the desk would cause it to always go in behind of the desk.
So, if I understand the idea correctly, I make a larger invisible sprite that is placed on the spot of the player, and is also then repelled by the walls? And then use that hidden sprite centre position for the tracking? Huh, I’ll give that a try.
Make sure the objects origin points are the same and the hitbox is as big or bigger. Try the invisible object’s X() or CenterX() properties. For a maze, I think this would be the best.
I’m not at my PC. Let me do some testing in a couple of hours.
Edit:
“So, if I understand the idea correctly, I make a larger invisible sprite that is placed on the spot of the player”
Just so we’re on the same page. My idea was to place the hidden sprite where the player taps or clicks the screen. The destination.
Edit: I didn’t see the link to the game. I understand now. Let me think about it.
Edit #2: I would have to test this but what if the hidden object that’s slightly larger than the glow object always followed the player through some form of force to player with a if collision then separate objects action to keep it from going through a wall.
My original impression of the game was that it used mouse touches for the destination. My thinking needs to change.
Original:
I’m not clear on your game. There seems to be 2 objects. Do they move independently? Both with a pathfinder? Does moving one cause the other to move?
OK, I finally got a chance to try this. My concept works for me. I decided instead of moving the duplicate all the time that it was best to only do it if path wasn’t found (inverted path found)
Player, light is object that follows the player, light2 is used to find a valid spot. I left it visible to show demonstrates how it works.
Use the arrow keys to move the player. The large circle is light2
Edit: With further testing it hangs up in corners. I think the test sprite just needs to be larger to allow more room. Also, I didn’t make a round hitbox for either object. So, that might also make corners tougher. I updated my game link with a larger sprite but the same square hitbox. (remember the larger sprite only moves if the smaller one can’t)
I was trying to apply the pathing to the hidden sprite on every frame change, but I never even thought to check if there was an event check for path failure!
Yes, the larger invisible sprite when needed is just perfect.