jwalkable icon indicating copy to clipboard operation
jwalkable copied to clipboard

Random NullPointerException

Open mattyoung101 opened this issue 7 years ago • 6 comments

Sometimes the pathfinder will throw a random NPE. I've been unable to consistently reproduce it, but I'm pretty sure it might be specific to certain positions in the world.

Here's the stacktrace:

java.lang.NullPointerException
	at hxDaedalus.data.math.Geom2D.getRelativePosition2(Geom2D.java:494)
	at hxDaedalus.ai.Funnel.findPath(Funnel.java:377)
	at hxDaedalus.ai.PathFinder.findPath(PathFinder.java:120)
	at com.dongbat.walkable.PathHelper.doFindPath(PathHelper.java:178)
	at com.dongbat.walkable.PathHelper.findPath(PathHelper.java:227)

It seems that in the method getRelativePosition2, either the eUp, eUp.get_originVertex() or eUp.get_destinationVertex() is null, but I'll have to test with some debugging code to be sure.

mattyoung101 avatar Jul 07 '18 08:07 mattyoung101

I'm pretty sure that it's the case the target position is inside entity's radius.
We can check that first and through an unchecked error.
Can you test that and make a PR for the lazy man :)

implicit-invocation avatar Jul 07 '18 09:07 implicit-invocation

Sure, I'll look into it and report back 😃

mattyoung101 avatar Jul 07 '18 09:07 mattyoung101

Any updates on this?

I have the same issue


java.lang.NullPointerException: Cannot invoke "hxDaedalus.data.Edge.get_originVertex()" because "eUp" is null
	at hxDaedalus.data.math.Geom2D.getRelativePosition2(Geom2D.java:494)
	at hxDaedalus.ai.Funnel.findPath(Funnel.java:377)
	at hxDaedalus.ai.PathFinder.findPath(PathFinder.java:120)

Ali-RS avatar Nov 29 '20 08:11 Ali-RS

Sorry, no updates right now. For the project I was working on, I ended up using gdx-ai's A* pathfinder instead, and then the project was abandoned a while later. If you can share some info about your setup and code that might help diagnose the issue.

mattyoung101 avatar Dec 02 '20 11:12 mattyoung101

Hi @mattyoung101

I am using this with jMonkeyEngine. This is a simple test and there is just one large rectangular obstacle in the scene and the player is inside the obstacle and can move inside it. Sometimes when I want to find a path from player location to somewhere inside the obstacle it throws this NPE.

Note, the target position that I want to find the path to it, is not inside entities radius.

Ali-RS avatar Dec 02 '20 11:12 Ali-RS

If there is no path, I believe that it won’t throw NPE when findPath is called.
It should be that the destination is inside entity’s radius or the destination combined with radius contains the obstacle.

Maybe you have some mistakes with the unit when debug drawing. Can you upload your current code so I can take a look?

implicit-invocation avatar Dec 02 '20 12:12 implicit-invocation