How to make sure a large polyline doesn't go off-road? - google-maps-api-3

I have an iOS app that uploads coordinates to a server. These coordinates can then be viewed in a map, through Google Maps. This is shown as a simple polyline. However, due to the GPS not being very precise, the polyline is often off-road.
I tried using Google's direction service, but it has a limit on how many requests you can send (and there can be a few thousand points on the polyline).
I have no idea how I can solve this problem. Could anybody help me?

I suspect the only way do do this is with manual intervention. The only way I can think of doing it programmatically would involve lots of queries to the directions service (to get "snap to road" functionality), and that probably would still need someone to check that it got it right (or at least need to include some code to look for extra loops to turn around or detours on to side roads that don't make sense).
Whereas if someone gets directions from start to end then drags them to match the track it would be pretty simple to get a version of the track that follows the roads.
The paper discussed in this thread might give you some ideas

Related

Pathfinding to a moving target

Working on a recent project I wondered how to find a good/perfect path to a target that is moving with a steady speed. I tried standart A* pathfinding but it failed, since the heuristic will be wrong the more the object moves and I just canĀ“t find a way to make that work for me. Maybe you guys got another algorith that should work with just fine or some calculation tuning with A* that would work...
Thanks for your afford :)
A* should in general work, but then of course you need to recalculate every time the target moves. For 99% of cases, this is actually ok. For example, in video games you can get away with only recalculating the best path once every second or so, so it's generally not a huge performance hit.
However, if you really need something more powerful, check out Generalized Adaptive A*, an algorithm specifically designed to handle moving targets. And if you really want to be on the bleeding-edge, there are multiple adaptations of GAA* that are faster in certain cases - see this post (under "moving target points") for more details.
Using A* with a moving target is ok, but you must recalculate the whole path again. I don't think A* likes just having it's destination / goal changed.
Your A* needs to be very well optimised to run in real time and recalculate the new path every time the target moves.
Remember to play with your H to get a balance between working out the shortest path and the quickest to calculate. All depends on your map and obstructions really.
However A* may not be the best path finder for your application, but I'd need to see your map and more info..

How do I adapt AStar in Godot to platformers?

I've been looking for a robust method of pathfinding for a platformer based game I'm developing and A* looks like it's the best method available. I noticed there is a demo for the AStar implementation in Godot. However, it is written for a grid/tile based game and I'm having trouble adapting that to a platformer where the Y axis is limited by gravity.
I found a really good answer that describes how A* can be applied to platformers in Unity. My question is... Is it possible to use AStar in Godot to achieve the same thing described in the above answer? Is it possible this could be done better without using the built in AStar framework? What is a really simple example of how it would work (with or without AStar) in GDscript?
Though I have already posted a 100 point bounty (and it has expired), I would still be willing to post another 100 point bounty and award it, pending an answer to this question.
you could repurpose the Navigation2D node for platformer purposes. The picture below shows an example usage. The Navigation2D node makes it possible to navigate the shortest path between two point that lie within the combined navigation polygon (this is the union of all NavigationPolygonInstances).
You can use the get_simple_path method to get a vector2 array that describes the points your agent/character should try to reach (or get close to, by using some predefined margin) in sequence. Place each point in a queue, and move the character towards the different points by moving it horizontally. Whenever your agent's next point in the queue is too high up to reach, then you can make the agent jump.
I hope this makes sense!
The grey/dark-blue rectangles are platforms with collision whereas the green shapes are NavigationPolygonInstance nodes
This approach is by no means perfect. If you were to implement slopes into your game then the agent may jump up the slope instead of ascending it normally. It is also pretty tedious to create all the shapes needed.
A more robust solution would be to have a custom graph system that you could place in the scene and position its vertices. This opens up the possibility to make one-way paths and have certain edges/connections between vertices marked as "jumpable" only. This is a lot more work though if you can not find any such solution online.

What's the best method to implement multiplayer on a Unity Billiard game?

I'm making an online billiard game. I've finished all the mechanics for single player, online account system, online inventory system etc. Everything's fine but I've gotten to the hardest part now, the multiplayer. I tried syncing the position of each ball every frame but the movement wasn't smooth at all, the balls would move back and forth and it looked "bad" in general. Does anyone have any solution for this ? How do other billiard games like the one in Miniclip do it, I'm honestly stuck here and frustrated as it took me a while to learn Photon networking then to find out it's not that good at handling the physics synchronization.
Would uNet be a better choice here ?
I appreciate any help you give me. Thank you!
This is done with PUN already: https://www.assetstore.unity3d.com/en/#!/content/15802
You can try to play with synchronization settings or implement custom OnPhotonSerializeView (see DemoSynchronization in PUN package). Make sure that physic simulation disabled on synchronized clients. See DemoBoxes for physics simulation sample.
Or, if balls can move along lines only, do not send all positions every frame. Send positions and velocities only when balls colliding and do simple velocity simulation between. This can work even with more comprehensive physics but general rule is the same: synchronize it at key points. Of course this is not as simple as automatic synchronization.
Also note that classic billiard is turnbased game and you do not have all the complexity of players interaction. In worst case you can 'record' simulation on current player client and 'playback' it on others.

Game programming implement chunks

i'm working on a simple game project with libgdx and i need some help to make a random infinite world. After googling for hours i knew that many games use the "chunk theory" to generate an infinite map and also implement tiles. There are many things i don't understand... for example:
What is a tile? and a chunk?
How can i implement this "chunk theory" in a game?
Is this the best way to generate an infinite random map?
can someone answer my questions to make some clarifications in my mind?
Thanks in advance
Tile-based maps are maps, which are organized as a grid. A Tile is then a cell of this grid and objects are placed inside this Tile/cell and can't be placed between to cells. Think about Minecraft, every Block there is one Tile.
A chunk is a part of the map, containing many Tiles. It has a fixed size and is used to be able to load only part of an infinite map.
Imagine a map with a size of 1600*1600 Tiles. You won't be able to see all Tiles at once. Also you don't need to update the logic for the whole map, as it won't affect you anyway. So you split your map into little parts, so called chunks, which have a fixed size (for example 16*16).
Depending on your position, adjacent chunks are loaded and far chunks are unloaded. So if you move from south to nord, chunks in the nord are loaded, chunks in the south are unloaded.
I never implemented a chunk-system myself, so i can't tell you how to implement it, but i guess there are many tutorials out there.
This is not the way to generate infinite maps, but the way to store, load and work with huge maps. The generation is usualy done with some noise functions, but thats a different story.
Anyways i suggest you to start with something smaller and simpler. Rushing into to complex things will just discourage you.

Box2D collision manifold?

I have seen around that there is a b2Manifold. What I want to accomplish is to detect whether or not a collision was on the top part or not of one of the objects that were colliding.
I have already set up a b2ContactListener and it works fine. I would just like to provide more accurate collisions by setting up the manifold to detect if one b2Body is on top of the other b2Body that it collided with.
How would I do this?
Thanks!
http://postimage.org/image/kbfr7c5db/

Resources