Although it's easy to find the shortest path between two points using NASolver, sometimes NAClassLoader.Load failed to map the points to the right road, NALocator only considers the closest distance.
For example, sometimes we have to judge a point's matching positon according to vehicle's previous tracks, at this time, it will make some mistakes if the loader maps the point to the closet road.
In the graph below, because point1 is on the green road, so point2 should also belongs to the green line but not the red ones. How can I tell the NALocator the right choice? Will NALocatorFeatureAgent work in this condition?
Related
I have this procedurally generated maze which I solve using the Navigation2D. It looks like this
I have turned Show Navigation on in the Debug menu hence the green outline. As the sprite takes a corner you can see it's taking the slanted line.
I want it to restrict itself to right-angled turns only. I configured the navigation polygon to 4 pixels wide, and the inverse of that polygon as my collision polygon so it's supposed to be a tight fit?. I am confused as to why there's that blurry outline at the vertices.
My repo is here https://github.com/plasticruler/tower-defence-maze
Also, any comments on why it doesn't always return the shortest path?
I've done some research and even tried to code it myself but sadly no positive results. You could try solving the maze by sending some "agents" with restricted 4 directional movements and the agent with the shortest path is your answer something like an Ant simulation Video I recommend watching about Ant simulation.
I also had found this useful video by GDquest that you might find helpfulVideo
I want to comeup with a point in the image its represented by (a) and (b) such that if I take a picture standing at that point the it presents better grouping of the items (balls)(better viewing advantage - green) . In reality the balls will be not properly organized and scattered around. Is there a way to tackle this mathematically?
So if i am travelling from direction (black arrow) I need to stop at some points (a), (b), etc.. depending upon scatter of the balls such that at single point, the balls capture can be maximized. If can stand at (a) for example in the picture I can take pictures in two directions so this is optimum point encompassing the balls on its left and a single ball on its right.
Assuming the cone has some angle, How shall I mathematically tackle this optimization problem?
I am looking for hints. The way I would tackle this is maximization problem by projecting verticle lines from each points/balls , centering my cone and moving as far such that maximum balls at one side can be captured, but the problem is there are balls/points in opposite side as well which might not align well.
First off, I am not sure if this is the right place so I apologize if this belongs elsewhere - please let me know if it does. I am currently doing some prototyping with this in VB so that's why I come here first.
My Goal
I am trying to make a program to be able to log different types of information for a video game that I play. I would like to be able to map out the entire game with my program and add locations for mobs, resources, etc.
What I have
The in game map can be downloaded so I have literally just stuck this in as a background image on the form (just for now). The map that I get downloaded though is not exactly as the map appears in the game though since the game will add extra water around everything when scrolling around. This makes it a bit tricky to match up where the origin for the map is in game compared to where it would be on the downloaded map.
The nice thing though is that while I am in the game I can print my current coordinates to the screen. So I thought that maybe I can somehow use this to get the right calculation for the rest of the points on the map.
Here is an example image I will refer to now:
In the above map you will see a dotted bounding box. This is an invisible box in the game where once you move your mouse out of the longitude and latitude points will no longer show. This is what I refer to above when I mean I can't find the exact point of origin for the in game map.
You will also see 2 points: A and B. In the game there are teleporters. This is what I would use to get the most accurate position possible. I am thinking I can find the position (in game) of point A and point B and then somehow calculate that into a conversion for my mouse drag event in VB.
In VB the screen starts at top-left and is 0,0. I did already try to get the 2 points like this and just add or subtract the number to the x and y pixel position of the mouse, but it didn't quite line up right.
So with all this information does anyone know if it is possible to write a lon/lat conversion to pixels based on this kind of data?
I appreciate any thoughts and suggestions and if you need any clarification of any information I have posted please let me know and I will be happy to expand on it. I am really hoping I can get this solved!
Thanks!
EDIT:
I also want to mention I am not sure if there is an exact pixel to lat/lon point for the in game map. I.e. the in game map could be 1 pixel = 100 latitude or something. So I might also need to figure out what that conversion number is?
Some clarifications about conversion between the pixel location to 'latitude and longitude'.
First the map in your game is in a geometry coordinate system, which means everything lies in 2D and you can measure the distance between two points by calculate the pixel position.
But when we talk about longitude and latitude, we are actually talking about a geography coordinate system, which is a '3D' model of the sphere oabout the surface of the earth. All the maps on earth are abstracted from 3D to 2D through one step called projection. Like google maps or your GPS. In this projection process, the 3D model converted to 2D model but there is always some part of the map will be tortured, so that same distance in pixels on a map could be different in length in reality.
So if you don't care about the accuracy then you can consider the geometry point as geography point. Otherwise, you need to implement some GIS library to handle the geodesic distance and calculate the geography point based on the projection coordinate system.
Examples of what i'm going to need:
I'm using cocos2d to draw a CCTMXTiledMap, on those tiles i'll have to draw the LOS triangle.
How would i test if the player is within that triangle, taking obstacles into account?
How would i draw the line of sight area like in the examples above?
BTW, i wasn't sure if this should have been posted here or on gamedev, don't be mad.
You may wish to look at point-in-polygon algorithms such as the ray casting algorithm described here.
You can break up the triangle to account for obstacles, or just make a more complex polygon. You should be able to find an implementation to suit your needs online.
You may also want to take a look at this article for some inspiration. You can maintain a tree like structure, a root triangle (or fulcrum) that can be used to determine whether a point is in general line of sight, with the children (triangles) taking obstacles into account. That way you can quickly eliminate more complex checks.
In the image below the dark blue dots are quickly eliminated from further checking as they do not fall within the root viewing triangle.
For those of you who have used bullet physics...
I read and ran the hello world example http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World,
and I am confused where to go next.
The hello world tutorial consisted of a btStaticPlaneShape and a btSphereShape, both rigid bodies. The sphere bounced on the static plane shape no problem.
However, I when I make another sphere at a different position, Bullet does not record collisions between the two sphere shapes, but it both automatically bounce off of btStaticPlaneShape. What kind of internal magic causes the btStaticPlaneShape to automatically bounce objects that collide with it?
Is there a setting in Bullet that automatically bounces objects off of each other after colliding? Or do you have to manually test for collisions and apply the resulting forces yourself?
Thanks.
You may have inadvertently created the spheres in a state where Bullet doesn't think they're supposed to be able to collide with each other. If you stick mostly to the defaults, and just add another sphere to the Hello World program, Bullet should notice and react to their collisions. They won't actually bounce unless you also modify Hello World to set their restitution to something greater than zero, but they will collide. For example, I added a second sphere directly above the first (by putting a for loop around the code block that creates the sphere, and using the loop variable to determine the origin y value) and extended the simulation so it runs long enough for them both to reach the plane. The first lands on the plane and rests there, the second lands on the first and rests there.
If this doesn't help, then posting some of your code is probably a good next step.