Libgdx drawing a circle with large radius causes exception When drawing a circle using the ShapeRenderer and using a really big radius (in millions, planet sun size, given in metres) libgdx throws an exception Exception in thread "LWJGL Application" java.lang.ArrayIndexOutOfBoundsException 20003 at com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20.color(ImmediateModeRenderer20.java 116) at com.badlogic.gdx.graphics.glutils.ShapeRenderer.circle(ShapeRenderer.java 880) at com.badlogic.gdx.graphics.glutils.ShapeRenderer.circle(ShapeRenderer.java 844) at com.kacpr.solar.system.Planet.draw(Planet.java 74) at com.kacpr.solar.system.SolarSystem.render(SolarSystem.java 66) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java 223) at com.badlogic.gdx.backends.lwjgl.LwjglApplication 1.run(LwjglApplication.java 124) This didn't happen when I used smaller values. The question I have is whether I'm doing something wrong using such high numbers for a radius and should scale this down before drawing (I use this radius for some other calculations) or is this a bug?


how to set volume of sound depending on the impulse a body receives in Libgdx Box2d? I am trying to set the volume of a bouncing sound of a ball depending on how hard the ball hits something. so the harder the ball hits a wall or a ground the more loud the bounce sound. I couldn't find anyway to get the impulse of a body other than the postSolve(Contact contact, ContactImpulse impulse) method inContactListner class. But i then realized that unlike the beginContact(Contact contact) method, postSolve(Contact contact, ContactImpulse impulse) gets called repeatedly until the contact ends. so it repeatedly plays the bouncing sound making it sound stalked and buggy. I cant use the beginContact(Contact contact) method because there is no way to get the impulse that the ball is receiving from this method. I tried to to use the velocity of the ball instead of impulse inside beginContact(Contact contact)but that didnt yield good results and found it very complicated as i had to consider both horizontal and vertical speeds. so my question is how can I make the sound play only once if i am using the postSolve(Contact contact, ContactImpulse impulse) method or is there any other solution to achieve what i am trying to do here?


testPoint not working libgdx I'm making a game like angry birds with LibGDX and box2d in which I want to drag a ball (instead of the bird) back before releasing it. I deploy with testPoint function when I touch down the screen, I check if the point is within the body of the ball or not but testPoint function never works exactly. Here's what I'm trying thanks so much public boolean touchDown(int screenX, int screenY, int pointer, int button) for(Fixture fixture bird.getBody().getFixtureList()) if(fixture.testPoint(screenX 100, (mapHeight screenY) 100)) 100 is scaled parameter draggedBird true return true return false


Libgdx OrthographicCamera culling problem with zooming When I set zoom on an orthographic camera to anything above 1 I get a strange black border on the bottom of the screen. I suspect that this might be some sort of culling problem. I use a viewport to control the game resolution, and no matter the size the borders are there. The camera is set on a direction ( 1, 1, 1) basicaly isometric. Also it is positioned well above to origin at (1113,1113, 1113). Far plane at 7777 near at 0.00001f. The ground plane is at 0,0,0 laying in the xz axis, with an other plane on top of it sligtly off to the left and with a 45 degrees on its axis to face the camera. Here is an image of the problem Posting code wont really help here since I only use defaults almost everywhere, but if you need it just tell.


Is it reasonable to use FreeType Won't it slow my game if I use FreeType lib and convert 2 fonts from .ttf instead of using preloaded BitmapFont .png? Or may be FreeType so fast, that I can use fonts both ways? All I need is to change color and size of my text. P.S. I use 3 fonts in my project


spriteBatch.draw is not getting overloaded I am following this tutorial from gamefromscratch.com tutorial 11. I am using libGdx framework in Android studio . public class OrthogonalTiledMapRendererWithSprites extends OrthogonalTiledMapRenderer public OrthogonalTiledMapRendererWithSprites(TiledMap map) super(map) Override public void renderObject(MapObject object) if(object instanceof TextureMapObject) TextureMapObject textureObj (TextureMapObject) object spriteBatch.draw(textureObj.getTextureRegion(), textureObj.getX(), textureObj.getY()) getting error in this line I am getting an unresolved error in the following line spriteBatch.draw(textureObj.getTextureRegion(), textureObj.getX(), textureObj.getY()) The code in render() method is public void render () Gdx.gl.glClearColor(1, 0, 0, 1) Gdx.gl.glBlendFunc(GL20.GL SRC ALPHA, GL20.GL ONE MINUS SRC ALPHA) Gdx.gl.glClear(GL20.GL COLOR BUFFER BIT) camera.update() tiledMapRenderer.setView(camera) tiledMapRenderer.render() I am new in game development please help me solve this error. Thanks in advance


Solid outline around block I'm creating a minecraft clone (for practice), and I'm trying to implement a feature in which the block that the player is looking at has a block outline. The way I do this is just by creating a GL LINES mesh that covers the edges of the block, and then translating it to the block position. I'm using the LibGDX framework to do this the outline ends up producing a ModelInstance. It partially works, but this is what it looks like As you can see, some of the pixels are getting rendered, but some aren't. My theory is that this is because of the depth buffer because the line is intersecting with the face, some of the pixels don't get rendered. So my question is, how can I ensure that the outline gets rendered solidly?


LibGDX How can I draw a line at a specific angle I'm working on a 2D platformer, shooter game and I'm attempting to draw a line to serve as a guide to indicate where the player is shooting. The line should be drawn from the player's sprite to the mouse's position. I need to draw a line between the player and the mouse, at the angle from the player to the mouse, how can I do something like this? Here is a concept picture to explain what I'm talking about


What causes undefined geometry to be drawn? I am currently using the polygonSpriteBatch of libgdx to draw triangles, rectangles and a concave polygon as border. After adding the concave polygon for the colored borders everything seems to break and random geometry appears (sometimes even with a gradient). Some Examples Here you can see on the left everything looks good and after drawing the additional rectangle with its border and removing the other borders you can still see some weird red regions. This is even more extreme. On the left part of the concave polygon is drawn with a different color, and after it despawns (on the right) there is still part of it left and other triangles not created by me are drawn. I am quite confident that all convex polygons are defined in counter clockwise ordering. In the past I had trouble with providing the correct TextureRegion and it still doesn't feel like my current implementation is how it should be, but it worked for simple rectangles and triangles. Currently I have a (3px) (3px) Region and all polygon vertices are between (0f,0f) and (3f,3f). Because I define all triangles of the polygons myself the short array given to the PolygonRegion for a rectangle looks like this (0, 1, 2, 3, 4, 5) and the corresponding Vector2 polygon array like this ((0.0, 3.0), (0.0, 0.0), (3.0, 0.0), (0.0, 3.0), (3.0, 0.0), (3.0, 3.0)) I experienced even more artifacts when executing this on android and for some reason drawing a small rectangle for each vertice (for debugging) fixed some of the artifacts above. This is quite a complex problem but I hope somebody knows what could cause such a behaviour.


Eclipse LibGDXgame doesn't load textures Our LibGDX project doesn't load textures after building on PC Android but when it's built from Eclipse using Ctrl F11 (Run Debug) everything is fine. What could be causing that?


render() can't seem to reference my sprite properly This is driving me a little crazy. We use libGDX, working on making a simple side scroller for fun. I've got it switching from screens alright, loading from my main menu into my level one class, which implements screen. public class levelOne implements Screen Don't know if that effects this. When I try to initialize my sprite, my editor (AIDE) highlights it. Gives me an error saying that there is no access to the variable, as it does when you declare something but don't use it. Texture faceTexture new Texture(Gdx.files.internal("faceSprite.png")) faceGuy new TextureRegion(faceTexture, 50, 50, 95, 95) Sprite player new Sprite(faceGuy) I do actually call up the sprite in render() though, batch.begin() Background batch.draw(backGround,0,0,2900,800) Player player.draw(batch) Enemies batch.draw(faceGuy, baddieOnePosition.x, baddieOnePosition.y, 150, 150) batch.end() It doesn't generate an error there, but trying to run it generates a crash. I can do a batch.draw of the texture, but every attempt at doing it as a sprite fails. I have it being initialized in show(), thought maybe making a new method to do so would help, but had the same result. The only way I've managed to make it work was to initialize it in render(), but that not only resets the sprites position multiple times a second, but I expect is also a memory hog. Help!


How to make the bullet stop accurately when destination is reached? In the below code, is the method I use to move a bullet to its destination and stop when bullet is near to destination. But the problem is the bullet is stopping not accurately, sometimes there's a small offset or span or sometimes is accurate depends on the angle. public Vector2 getVelocity(Vector2 currentPosition, Vector2 targetPosition) Vector2 targetDirection targetPosition.cpy().sub(currentPosition) return targetDirection .nor() final float SPEED 6 float pos bulletPosition.len() float des bullet.destination.len() float tol Constants.TIME STEP SPEED if(MathUtils.isEqual(pos,des, tol)) body.setLinearVelocity(0,0) else body.setLinearVelocity(getVelocity(bulletPosition, destination).scl(SPEED)) SOLVED if(MathUtils.isEqual(pos, des, tol)) quick amp dirty way body.setTransform(destination, angle) better way ...


LibGdx Positioning the camera I've been following some tutorials about libGdx and I've tried to create a 2d platformer but I've got stuck at how would be the right way to make the camera not go out of the screen when the player moves ( The camera follows the player when it moves on the x coordinate position but if i go near where the map ends the camera will go out of the screen and i'm not sure how to solve that Here is the main code of the game public PlayScreen(SuperShooter game) this.game game atlas new TextureAtlas("Diz Pack.atlas") gamecam new OrthographicCamera() gamePort new StretchViewport(SuperShooter.V WIDTH SuperShooter.PPM, SuperShooter.V HEIGHT SuperShooter.PPM, gamecam) hud new Hud(game.batch) mapLoader new TmxMapLoader() map mapLoader.load("Level1WithObjects2.tmx") renderer new OrthogonalTiledMapRenderer(map, 1 SuperShooter.PPM) initailly set our gamecam to be centered correctly at the start of gamecam.position.set(gamePort.getWorldWidth() 2 , gamePort.getWorldHeight() 2, 0) world new World(new Vector2(0, 10), true) new B2WorldCreator(world, map) controller new Controller(game) b2dr new Box2DDebugRenderer() player new John(world, this) world.setContactListener(new WorldContactListener()) public void update(float dt) handleInput(dt) world.step(1 60f, 6, 2) in order for box2d to execute our physics simulation we need to tell it how many times to calculate per second player.update(dt) gamecam.position.x player.b2body.getPosition().x gamecam.update() renderer.setView(gamecam) public void render(float delta) update(delta) Gdx.gl.glClearColor(1, 1, 1, 1) Gdx.gl.glClear(GL20.GL COLOR BUFFER BIT) renderer.render() render our Box2dDebugLines b2dr.render(world, gamecam.combined) game.batch.setProjectionMatrix(gamecam.combined) game.batch.begin() player.draw(game.batch) game.batch.end() game.batch.setProjectionMatrix(hud.stage.getCamera().combined) you have something that can draw to the screen via gpu like the spritebatch. And you have a camera. you gotta tell the spritebatch where we are where the camera is looking, because on screen shall be what the camera is looking at. hud.stage.draw() controller.draw() The camera is at first set on the left bottom of the screen but then, while the game updates it's placed on the x position of the player and that's why it looks like that ( do you guys know how should it be done to show only the map when the player moves? should i position the camera in front of the player or something like that? Help would be appreciated! thanks


libgdx using more than one class Hi i am very new to programming and in this community,so im recently studying on how to develop games with libgdx and all the tutorials only have one class and do all the things in that class,but is it possible to use more than one class?(ex individual class for player, mobs , etc) thanks!


Libgdx How to overlay two images on Table I'm trying to set the player image inside the circle of the bars. I've tried to use stack, to position it topLeft but it does not work. Stack stack new Stack() healthbar new Image(new Texture(Gdx.files.internal("data ui healthbar.png"))) playerLook new Image(player.getFrame()) stack.add(healthbar) stack.add(playerLook) Table table new Table() table.top() table.setFillParent(true) table.add(healthbar).expandX().pad(10).left() table.add(playerLook).expandX().pad(10).left() stack.add(table) stage.addActor(stack)


Lib GDX GWT build will not load without Flash on some browsers I am trying to load my LibGDX application. Using Firefox without Flash on a freshly installed Ubuntu system, it does not load. I get this printed in the console SoundManager No Flash detected. Trying HTML5 only mode. soundmanager2 jsmin.js 32 357 SoundManager V2.97a.20130512 (AS3 Flash 9) HTML5 audio soundmanager2 jsmin.js 32 357 lt br gt SoundManager 2 soundManager Fatal error Flash is needed to play some required formats, but is not available. soundmanager2 jsmin.js 32 357 SoundManager 2 HTML5 support mp3 false (using flash), mp4 false (using flash), ogg true, opus true, wav true soundmanager2 jsmin.js 32 357 soundManager No Flash response within expected time. Likely causes Flash blocked or JS Flash security error. soundmanager2 jsmin.js 32 357 soundManager Waiting indefinitely for Flash (will recover if unblocked)... And this on my screen I am assuming this is because of the lack of Flash and the fact that these audio formats are not supported in this version of Firefox. However, I am not using any audio in my game at all. In my LibGDX HtmlLauncher, I have public GwtApplicationConfiguration getConfig () GwtApplicationConfiguration config new GwtApplicationConfiguration(getWindowInnerWidth(), getWindowInnerHeight()) config.preferFlash false return config This did not fix anything. I am on the latest version of LibGDX, and the latest GWT SDK version. How do I fix this?


Optimal way to create spawn multiple sprites in mini2dx(subset of libgdx) What is optimal way to spawn new sprites with different sizes in mini2dx(subset of libgdx)? Currently I am maintaining ArrayList of enemy sprites private ArrayList lt Sprite gt enemies new ArrayList lt Sprite gt () In the generateEnemies method private void generateEnemies() How many enemies to spawn max?? X for (int i 0 i lt 5 i ) float size (float) Math.random() 3 float speed (float) Math.random() 3 float y (float )Math.random() Gdx.graphics.getHeight() enemies.add(new Enemy(new Texture(Gdx.files.internal("gfx enemy.png")))) enemies.get(i).setScale(size) enemies.get(i).setSpeed(speed) enemies.get(i).setPosition(0, y) In render method for (int i 0 i lt 5 i ) g.drawSprite(enemies.get(i), collisionPoint.getRenderX(), collisionPoint.getRenderY()) Although I seems to render the enemy but there is no control over the enemy sprite to respawn. Is there any optimal way to do it?


Libgdx getting screen size I'm working on libgdx project. I basically recreate my game which I coded in xna to make it available for android. Here's the problem android has many screen resolutions, and I want to know how to get them. i tried Gdx.graphics.getWidth() or getHeight() but it gives me null pointer exceptions.


How do I derive an appropriate acceleration value for my game? I am creating a Flappy Bird clone from this tutorial. I have a question about acceleration in libgdx. The author assigned the bird a constant acceleration vector in the constructor of the bird acceleration new Vector2(0, 460) and later updated the velocity vector from the accleration vector with velocity.add(acceleration.cpy().scl(delta)) I understand generally why acceleration is constant like the author mentioned, acceleration due to gravity is 9.81m s 2, meaning that the speed of an object falling will increase by 9.81m s every second. It seems the author somehow got from 9.81 real world value to 460 in the actual code. How does one go about deriving this value? Is this a standard derivation or something the author just made up?


Semi transparent mouse cursor on Windows I want to change the mouse cursor for a desktop game I am writing with libGDX. That is working well under Linux, however, under Windows semi transparent cursor pixels are not being rendered at all. That means I am unable to anti alias the cursor image. For sure there must be a way to render semi transparent mouse cursors under Windows, like it's possible under Linux. Any ideas what I could do to solve this issue?


LibGDX TextureRegion renders correctly, but .getTexture() doesn't I have a TextureRegion that I get from an atlas map (which in turn I get from the Asset Manager), eg AssetManager am myGame.getAssetManager() TextureAtlas atlas am.get("my.atlas", TextureAtlas.class) TextureRegion object atlas.findRegion("myobject") Now when I draw the object with batch.draw(object, ...) the object is drawn correctly, but if I do batch.draw(object.getTexture(), ...) it is drawn as garbage. Is this expected? I thought it should work the same.


Libgdx FPS drop drawing alot of text i'm drawing text above monster head and it's fine. But when there is to many monsters and their name gets render every second cause fps go down. When i disable the font drawing, then the fps is fine. Any id a how to tackle this perfomence issue? Thanks.


Handling bad network clients using socket.io Currently I'm working on a MMO game which players can join and exit game whenever they want. I have a connection manager server (CMS) written in golang using socket io library. World connects to CMS and clients connect to CMS and talk to world and world update clients with snapshots of game state. For testing I wrote a client that connects to CMS and act as a player for testing how many clients can my CMS handle. I reach around 80 clients per one core vcpu and 1 gig ram and that's acceptable for my game and resources. I released the game but in real life when there is around 5 or 6 real players and one player with bad network connection joins game it massively take effect the another players game experience. Packets don't receive to another clients or delayed heavily! I believe it's because socket io uses tcp and when a bad network client joins it should send messages many times for client received it completely. How should I overcome this? I know I should used udp for my game but it's too late and I released my game in play store and it got around 700 installs. Is there anyway I can put a time to live like attribute to messages that if client don't received them at a certain time dropped them? Any idea whould be helpful.


How can I update a Stage based HUD from another Stage's Actor in libGDX? I feel like this is a simple problem, but I'm having issues finding the correct search terms. I have a Screen that includes two Stages. The first, stage, contains a number of objects deriving from Actor and added via the standard stage.addActor(Actor). This is for the actual game objects. The second, hudStage, consists of a single Table actor. This table includes a button as well as two Labels. This is for the static user interface HUD. I'm handling touch events on my custom actors in the game stage like the following public class GameObject extends Actor private final static String TAG GameObject.class.getName() ... public GameObject() ... addListener(new InputListener() Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) Gdx.app.log(TAG, "touchDown on GameObject actor lt " x "," y " gt ") return super.touchDown(event, x, y, pointer, button) ) This works perfectly and logs what I need. However, I would now like to update the HUD with information about the object the user touched. My screen has defined the Label I want to update (added via hudStage), but I'm not sure how to go from an actor in stage to the screen, or to the hudStage label. public class GameScreen implements Screen Stage stage Stage hudStage This is the label I want to update. Label infoLabel ... I know I can call setText(String) on the label, but I'm not sure the best way to bubble the click up. Plenty of examples have simplified versions where objects are defined in the main class (in my case, GameScreen) and are able to refer to them that way, but I've already broken these apart. I started to look at creating a custom event that my actor could trigger, and that the stage would handle, but documentation is sparse and I'm not sure this is required. I've also thought about scrapping the idea of having a label in the hudStage and instead having my actor draw text where the HUD would have. However, from what I continue to see, I think Scene2D is the right direction to go for the UI. Thanks! EDIT What I'm looking for An actor in GameScreen.stage is target of a touchDown event. Logic in actor fires and updates object. touchDown event in actor finishes by updating infoLabel in GameScreen.hudStage or updates String value in GameScreen (if easier, I'll go this route).


How can I implement an asset update download in a libgdx application? I am building a game based on libGdx and I want to be able to check for and download updated assets at some point before the player starts playing. The game is being built for PC and for Android. I haven't been able to find much on downloading assets. It seems libGdx assumes all assets will be packaged with the game or already on "external" storage and available for the AssetManager. So far, the best option I've found is setting up updating code prior to starting the libGdx application. How can I have my assets download while the libGdx application is running? Possibly to allow some interaction while waiting, or progressive asset downloads allowing limited game play. My goal is to allow for dynamic updates to assets, and to allow users to get into the game quicker. Especially new players, I don't want them waiting on a download screen before they see anything of the actual game.


Deleting Cleaning Screen Objects with all child objects in libGDX For my game, Im using libGDX Ashley (ECS) Box2D Ive got a lot of screens but for simplification MainMenuScreen and InGameScreen. In InGameScreen Im init the ECS (Ashley) and create a lot of entities. Some have PhysicsComponent. The PhysicsSystem will catch them and call Box2D to spawn some objects based on the parameters within the PhysicsComponents. So far so good. Now, when the player dyes, I run setScreen(new MainMenuScreen()) from my "Main" Class (MyGame.java). the game starts and MyGame loading at first the MainMenuScreen than the InGameScreen will get loaded (when player presses a key) than the player dyes MyGame recognized it and loading again (throu calling setScreen(...)) the MainMenuScreen When Player press key MyGame loading another round (setScreen(new InGameScreen)) I guess I have to do something like a complete clean up between switching screens. But how should I implement this? Just "deleting" the old InGameScreen Object shouldent be enought, right? Do I have to use the dispose() Method? Is it enough to instantiate everything new (in the init from InGameScreen) since it will instantiate all child object new for its own like Box2DWorld world new World()


Porting libgdx game to iOS using Multi OS engine how to add Admob ads I want to port my libgdx game to iOS using Multi OS (RoboVM is no longer available). I've searched whole internet but can't find any info about how to use Admob with Multi OS engine on iOS. Every resource I found is about RoboVM, but it's not available anymore since April 17 for new developers (you can only use it if you already have an account, but it's not possible to create a new one). Libgdx with Multi OS is available in another branch on Github, but there is no info about ads and I want to publish my game this week. Can anyone help me?


Using libraries in libgdx This is the first time I'm using libgdx and I've got one problem. I am confused by the web of dependencies and the number of projects and I'm not sure how and mostly where to add a third party library I want to use. It should work both for desktop and android. How is this done?


Handling data logic on libgdx ai state machine or in ashley system? In this below example, I've combined libgdx ashley and AI state machine. Do you think it's a good idea to handle the logic in state machine or stick on handling the data logic on System? public enum TrollState implements State lt Entity gt MOVE AWAY() Override public void enter(Entity entity) Override public void update(Entity entity) PositionComponent position Mappers.position.get(entity) ... Override public void exit(Entity entity) Override public boolean onMessage(Entity entity, Telegram telegram) if (telegram.message 0) Gdx.app.log("Slime", "Waaaah, goo away, big daddy! yummmmmmy") return true return false


How can I append geometrical objects over a circle LibGDX I want to draw geometric shapes over circle with using the graphics library in LibGDX like that As you see from image, I want to append blue shapes to black circle. Any advice ?


How to implement dynamic background music? Assumption 1 As a game's story progresses, dynamic background music is often used to enhance the player's immersion. Assumption 2 Background music is probably always streamed due to memory limitation and performance. What do I need to consider when I'm checking the feasibility of having dynamic(ally changing, adapting) background music? For example when a boss enemy appears the game should not just replace the "wandering music" to "boss combat", it should rather somehow cross fade the two music scores as it starts playing the new music. Is it usually possible to stream multiple sounds in parallel? I'm using LibGDX, where as far as I'm aware only a single streaming music instance can be played at a time, so how can I have such music with this framework? Do I suspect correctly if I also need to separate a dynamic music into parts like "intro", "loopable part", "loopable part near the climax", "outro", etc., and when a part ends have a music manager code decide which part should be (re)started? I'm more interested in understanding the theory instead of the actual implementation of the code.


LibBDX create a tail when the object is moved I am looking for a way to implement in my game a kind of shadow tail which will be displayed after the object is moved. Should I use animation? If yes how? Here an example


Use Stage's draw() method to invoke Actor's draw method in Libgdx Question In the following snippet, I wish to draw different shapes such as rectangles, circles, triangles etc. I will be creating different class files for each of such objects, as I did for Rectangle class here. I've been trying to invoke the draw method of Rectangle object from Stage object, but I am unable to do so. If I make a plain call to the draw method of the Rectangle object, I can draw the object. Can some one suggest me how is this possible ? Also, I had many other queries which I'd tried to put in comments. Please have a look at them and kindly help me in figuring out the concept beneath it. Disclaimer I am new to game programming, started with Libgdx. Following is the Scan class package com.mygdx.scan.game import com.badlogic.gdx.ApplicationAdapter import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.GL20 import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType import com.badlogic.gdx.scenes.scene2d.Stage public class Scan extends ApplicationAdapter private Stage stage public static ShapeRenderer shapeRenderer Override public void create () stage new Stage() shapeRenderer new ShapeRenderer() Rectangle rect1 new Rectangle(50, 50, 100, 100) stage.addActor(rect1) Override public void render () Gdx.gl.glClearColor(1, 1, 1, 1) Gdx.gl.glClear(GL20.GL COLOR BUFFER BIT) shapeRenderer.setProjectionMatrix(stage.getCamera().combined) shapeRenderer.begin(ShapeType.Filled) shapeRenderer.setColor(Color.BLACK) new Rectangle(50, 50, 100, 100).draw() shapeRenderer.end() This should call Rectangles draw method. I want a Shapetype.Filled Rectangle. But I'm unable to invoke this method if I add the actor in stage object and invoke it's draw method. stage.draw() public void dispose() stage.dispose() Following is the Rectangle Actor class package com.mygdx.scan.game import com.badlogic.gdx.scenes.scene2d.Actor public class Rectangle extends Actor float xcord, ycord, width, height public Rectangle(float x , float y , float width, float height) this.xcord x this.ycord y this.width width this.height height This needs to be called in the Scan class. I just want the draw method to be invoked. Also I wish to draw many such rectangles. What is the best practice to get hold of ShapeRenderer object from Scan class ? Should I use one instance of ShapeRenderer object in Scan class or should I create ShapeRenderer object for each of the Rectangle object ?? I also plan to repeat the activity for another object such as circles. So I would like to know the best practice here. public void draw() Scan.shapeRenderer.rect(this.xcord, this.ycord, this.width, this.height)


How Can I Monetize With Startapp A Libgdx Game Made With Aide I have created a libGDX game with the AIDE IDE Android app. The game is working fine so I will be uploading it to the Play Store to make money. I'd like to use Startapp ads, how would I integrate it? I Will Using Aide Premium


TiledMap renders but gets duplicated when I move the camera I've created a map (TMX file) using Tiled, imported it and it shows great but when I move the camera, it duplicates itself and the whole screen flickers. In Tiled, I didn't use a spritesheet but rather a collection of images as they have different sizes. See attached image Here is my game class public class MyGdxGame extends ApplicationAdapter private IsometricTiledMapRenderer renderer private OrthographicCamera camera private TiledMap map private Vector2 dragOld, dragNew Override public void create() map new TmxMapLoader().load("isometric map.tmx") renderer new IsometricTiledMapRenderer(map) camera new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()) camera.position.set(Gdx.graphics.getWidth() 2, Gdx.graphics.getHeight() 2, 0) Gdx.input.setInputProcessor(new InputAdapter() public boolean touchDown(int screenX, int screenY, int pointer, int button) if (button Input.Buttons.LEFT) dragNew new Vector2(Gdx.input.getX(), Gdx.input.getY()) dragOld dragNew return true return false ) Override public void render() super.render() camera.update() renderer.setView(camera) renderer.render() if (Gdx.input.isTouched()) dragNew new Vector2(Gdx.input.getX(), Gdx.input.getY()) if (dragOld ! null !dragNew.equals(dragOld)) camera.translate(((int) dragOld.x dragNew.x), ((int) dragNew.y dragOld.y)) Translate by subtracting the vectors camera.update() dragOld dragNew Drag old becomes drag new. Override public void resize(int width, int height) super.resize(width, height) camera.viewportWidth width camera.viewportHeight height camera.update() Override public void dispose() super.dispose() map.dispose() What am I missing?


Libgdx handle screen resolutions I know there are some questions to this topic, but i didnt find a satisfying answer for my problem yet. I'm learning to use libgdx right now, and I'm not sure about handling different screen resolutions. I can use Viewports and a Camera of course, to fit the content to the screen. But how do i achieve, that my game doesnt appear kind of stretched if a device has a different resolution? For example Do you know the game Clash Royale? It feels like this game looks the same on all devices with every different resolution and screen size. How do they do this? Thank you.


Smooth camera movement between followed objects I have 2d game where my camera follows the player. Simplified, it copies the player position as its own. Now I have some other object in the game, that I want to camera to follow. This is easy enough by not setting the camera's position with the player's, but with the position of the other object. The problem is that this camera movement is instant. I'd like to have a more smooth transition (e.g. panning over the level to the given object). How can I achieve this?


What is the difference between Sprite and SpriteBatch, specifically in the context of libGDX? I'm using libGDX and I'm confused about the difference between the Sprite and SpriteBatch. Anybody can explain it to me in a simple way?


Deploying GWT application LibGDX and TextureAtlas problem I encountered with a little problem. After GWT (and LibGDX) deployment I got an error GwtApplication exception Couldn't load image ' images objects.png', file does not exist Couldn't load image ' images objects.png', file does not exist This error throws when TextureAtlas tries to load the image from settings.text file images objects.png format RGBA8888 filter Nearest,Nearest repeat none hills rotate false xy 0, 0 size 1024, 146 orig 1024, 146 offset 0, 0 index 1 I tried to use any type of path " assets images object.png" " clutchkick assets images object.png" " public html clutchkick assets images object.png" and so on.. Any suggestions? By the way there are no any problems on android or desktop deployment. EDIT The same problem occurs when trying to load a Tmx map.


undo touchdown in LibGDX with scene2D i'm making a game in libgdx and i have a question. I have a Button from scene2d. If there is a touchDown event on this button, i want the touchUp event only inside my button. Now if i touchDown a button, then swipe outside my button, libgdx consider this like a touchUp. I know that i can extend stage and work with it, the question is if there is a simple way to do this...


LibGDX How to draw a filled rectangle behind a text? I'm new in LibGDX and I want to create a grid based game. Every square will have a rectangle and a text and the background color of the rectangles can change during the game. The problem is when I draw a filled rectangle with ShapeRenderer, it always in front of the BitmapFont. How can I set the rectangle behind the text? The code I use to draw the squares Draw numbers and rectangles for (int i 0 i lt map.length i ) for (int j 0 j lt map 0 .length j ) String value String.valueOf(map i j .getNumber()) float offset fontSize 3f Rectangle rect rects i j shapeRenderer.begin(ShapeRenderer.ShapeType.Filled) shapeRenderer.setColor(150 255f, 150 255f, 150 255f, 1) shapeRenderer.rect(rect.x, rect.y, rect.width, rect.height) shapeRenderer.end() Draw font if (map i j .isActive()) fontActive.draw(batch, value, rect.x offset, rect.y offset) else font.draw(batch, value, rect.x offset, rect.y offset) Thanks all!


Using libGdx and Box2d for game and getting this error "incorrect checksum for freed object" I am new in game development and I am using libGdx with box2d in my game, whenever I try to switch screen (both screens has box2d bodies with Tiled map), I encounter the following error. java(610,0x70000297a000) malloc error for object 0x7f8d642fd600 incorrect checksum for freed object object was probably modified after being freed. set a breakpoint in malloc error break to debug The code which I use to switch screen is in render method if((mapPixelWidth 200) lt frog.body.getPosition().x PPM) game.gm.setPrefLevel(0) Gdx.app.postRunnable(new Runnable() Override public void run () Array lt Body gt bodies new Array lt Body gt () world.getBodies(bodies) for (Body b bodies) world.destroyBody(b) ) game.manager.unload("maps World1Level3.tmx") game.setScreen(game.levelLoading) Apart from this error, I want to ask that the way I am using Asset Manager and Box2d bodies are correct or not?


"Pixel perfect" camera positioning in 2d game I am writing a 2d game using LibGDX. The view to the game world is top down. The game shows a grid of lines, which looks nice when the camera is at its initial position (0,0). The problem is now that when I move (shift) the camera left right up down this grid sometimes becomes a bit blurry, so the lines do not look perfectly sharp any more. I assume this is because in these cases the grid lines are not exactly on screen pixels, but somewhere in between. Is this correct? In any case Are there any "best practices" how to address this problem (not necessarily LibGDX specific)?


Two pass blur shader using libgdx tile map renderer I am trying to apply the following technique blur effect using two pass shader to my libgdx game using the OrthogonalTiledMapRenderer. The idea is to blur the background wich is also a tilemap but rendered with another camera with a different zoom applied. Here is a screen capture without effect Using the OrthogonalTiledMapRenderer sprite batch like this backgroundMapRenderer.getSpriteBatch().setShader(shaderBlurX) backgroundMapRenderer.render(layerBackground) I get the following render Wich is ok for X blur pass. I then try using frame buffer object like in this example. But the effect seems to be too much zoomed I may be messing up with the camera and the zoom factor. Here is the code private ShaderProgram shaderBlurX private ShaderProgram shaderBlurY private int FBO SIZE 800 private FrameBuffer targetA private FrameBuffer targetB targetA new FrameBuffer(Pixmap.Format.RGBA8888, FBO SIZE, FBO SIZE, false) targetB new FrameBuffer(Pixmap.Format.RGBA8888, FBO SIZE, FBO SIZE, false) targetA.begin() Gdx.gl.glClearColor(1, 1, 1, 0) Gdx.gl.glClear(GL10.GL COLOR BUFFER BIT) backgroundMapRenderer.render(layerBackground) targetA.end() targetB.begin() Gdx.gl.glClearColor(1, 1, 1, 0) Gdx.gl.glClear(GL10.GL COLOR BUFFER BIT) backgroundMapRenderer.getSpriteBatch().setShader(shaderBlurX) backgroundMapRenderer.render(layerBackground) targetB.end() TextureRegion back new TextureRegion(targetB.getColorBufferTexture()) back.flip(false, true) backgroundMapRenderer.getSpriteBatch() .setProjectionMatrix(backgroundCamera.combined) backgroundMapRenderer.getSpriteBatch().setShader(shaderBlurY) backgroundMapRenderer.getSpriteBatch().begin() backgroundMapRenderer.getSpriteBatch().draw(back, 0, 0) backgroundMapRenderer.getSpriteBatch().end() I know I am making something the wrong way, but I can't find any resources about applying two passes shader using tile map renderer. Does someone know how to achieve this?


Box2d set sprite to body that rotates around specific point I want to rotate kinematic body around a specific point (I already done this part using shape.setAsBox(1.8f PPM, 0.2f PPM, new Vector2(5.2f, 0), 0) What I try is this PolygonShape shape new PolygonShape() shape.setAsBox(1.8f PPM, 0.2f PPM, new Vector2(5.2f, 0), 0) !!!! FixtureDef fdef new FixtureDef() fdef.shape shape fdef.filter.categoryBits categoryBits fdef.filter.maskBits Constants.PLAYER bDef.position.set(((V WIDTH 32 3) 2) PPM, y PPM) body world.createBody(bDef).createFixture(fdef).getBody() body.setAngularVelocity(1f) body.setUserData(new BodyUserData(categoryBits, colorArray 0 )) sprite.setOrigin(sprite.getWidth() 2, sprite.getHeight() 2) sprite.setPosition( body.getPosition().x 32 sprite.getWidth() 2, body.getPosition().y 32 sprite.getHeight() 2 ) and here how I draw sprite public void draw(SpriteBatch sb) sprite.setRotation(body.getAngle() MathUtils.radiansToDegrees) sprite.draw(sb) Unfortunately my sprite position is not the same as my body. It seems that sprite is rotating around it's center, not my point. Is it possible to fix that?


Am I using libGDX Asset Manager correctly? My understanding is that you initialize the AssetManager as a non static object in your main class and load the sprites you need... manager new AssetManager() manager.load("sprite sheet.txt", TextureAtlas.class) manager.finishLoading() I then modified my abstract State class by adding AssetManager to the constructor... State(GameStateManager gsm, AssetManager manager) this.gsm gsm this.manager manager Now say I have 5 blocks in my sprite sheet called block0, block1... block5 would it be appropriate to create a BlockTextures class like this? private static TextureAtlas textureAtlas public BlockTextures(AssetManager manager) textureAtlas manager.get("sprite sheet.txt", TextureAtlas.class) public static AtlasRegion get(int id) return textureAtlas.findRegion("block" id) public static void dispose() textureAtlas.dispose() Where I call BlockTextures.dispose() in my Game.dispose() method? public void dispose() BlockTextures.dispose() While this code seems to work fine I feel like I am not using AssetManager correctly.


SelectBox in LibGDX doesn't display and freezes the program after a click I am currently trying to apply an overlay with LibGDX over my 3D ModelBatch. Everything works fine except for the SelectBox. Once instanciated, it shows up on my screen I can click on it once but then it freezes. The drop down list is not displayed and the clicks are no longer registered by my application. However, if my second click is under the standard position of the list, that is where it should be drawn when it drops down, an item is selected but then any third click will just return the list to the original selected item and no click is registered by my application anymore. I am running the application on Desktop. Using break points in the SelectBox.class I was able to notice that the third and other next clicks are registered by the SelectBox.class as part of the list in the Listener responsible for selecting an item. selectBox new SelectBox lt Object gt (skin) selectBox.setItems(array) selectBox.setSelected("Custom") stage.addActor(selectBox) array in this case is an instance of Object containing only Strings. This is the only part of code I have related to the selectBox. I have tried using an array of String at first but then switched to Object as suggested on a LibGDX forum. I am currently using the latest Nightly Build of 2014 04 11 as I also need TextArea which is not yet in the stable release. However, I have tried the stable release 0.9.9 and it doesn't work either. Am I using the right code to declare my SelectBox, or what could I do to make the SelectBox behave properly that is display its list when clicked and return to a normal state after an item is selected?


How can I add background color to a libGDX TextButton? I have a TextButton in my libGDX project and I want to add a color background to it. I tried the setColor() method but that didn't work.


Can I use JBox2D on server with Box2D on libGDX on client? I want to use Box2D for my turn based game, made with libGDX. The client is supposed to do some prediction of physics after his input and I want to correct these calculations with server side calculations afterwards. As I do not want to run an entire libGDX project on my server (because there will be parallel games and a single game per GameRoom is not necessary), I thought about running JBox2D on the server and send the final calculations for correction purposes to my two clients. Can I e.g. step 10 seconds ahead at once with my server side physics and send the results to my client right away? I don't need small steps, because the server won't render them anyways Will these results mostly match with the client results of the built in libgdx box2d version? I will here use smaller steps, so the client can render the changes easily. Thanks in advance!


How does mass work in Box2D I'm making a 2D platformer, shooter type game in LibGDX, and I'm wondering about Box2D's mass system. I'ven't used mass for anything in the game so far, and everything has worked ok. We move the player, enemies, and bullets around by body.applyLinierImpulse(new Vector2(impulseX, impulseY), body.getWorldCenter) and even have a variable jump height system, and it all works fine. To change the speed or impact of objects, we just change the impulse. I've tried using aplyForce() but it won't move the body. Everything is usually just a simple polygon, but when I'm creating fixtures there's an option to set the density, and bodies have the option to set the massData, but I don't know what either of these properties does. The gravity of the world is around 11. Can anyone tell me how I should be handling mass with my objects in the game? Thanks.


LibGDX Managing a Minimap I'm making a top down strategy game so I thought a minimap is a must. I'm using Scene2D to display my GUI and since the minimap is technically a part of the GUI, I used the stage camera to position the minimap. Below is how I'm rendering the minimap. shape.setProjectionMatrix (stage.getCamera ().combined) shape.begin (ShapeType.Filled) shape.setColor (Color.CYAN) shape.rect ((Constants.RENDER WIDTH 500) ship.getX () 30, ship.getY () 30, 5, 5) shape.end () shape.setProjectionMatrix (stage.getCamera ().combined) shape.begin (ShapeType.Line) shape.setColor (Color.YELLOW) shape.rect (Constants.RENDER WIDTH 500, 0, 500, 500) shape.setColor (Color.WHITE) shape.rect ((Constants.RENDER WIDTH 500) (camera.position.x) 30, (camera.position.y camera.viewportHeight 2) 30, Constants.RENDER WIDTH 30, Constants.RENDER HEIGHT 30) shape.end () The first ShapeRenderer (shape) call renders the ship marker, which is currently a small square. The second renders the bounds of the minimap which is 500x500. RENDER WIDTH and RENDER HEIGHT are the width and height that I'm plugging into camera as viewport dimensions (1920x1080). The map is 15000x15000, so I'm dividing the ship location by 30 so that it is always in the range of 0 500. However, when I move the camera around I actually end up being able to see the ship before the minimap says I should, which is illustrated below. I'm fairly certain it's due to the zoom level of the camera, but I haven't figured out how to incorporate that other than multiplying the width and height of the display of where the camera is (the white box), by the current zoom level, which didn't work.


Pause Tiled animation during game in LibGDX I m using Tiled with LibGDX and I have some animated tiles. When the game is paused I would like their animation to be paused as well. Is this possible? The map is drawn with mapRenderer.render() and if I'm not mistake, this is the class responsible for getting the corresponding animation. There doesn't seem to be a way to freeze time. Any help appreciated, I've been searching for a couple of hours and cannot find anything.


How do i initialize and use a Texture Array? LibGDX First of all, I am new to Java and LibGDX.. What I am trying to do is Load my texture images into an array so that I can reference them in my drawing code by number, rather than by name. I am drawing a tile map. Instead of this tile1 new Texture(Gdx.files.internal("grass.png")) tile2 new Texture(Gdx.files.internal("dirttile.png")) tile3 new Texture(Gdx.files.internal("watertile.png")) I would like it to be more like tile 1 new Texture(Gdx.files.internal("grass.png")) tile 2 new Texture(Gdx.files.internal("dirttile.png")) tile 3 new Texture(Gdx.files.internal("watertile.png")) ..so that later I can draw them by which tile I need..such as tileType worldMap i j will be an int number batch.draw(tile tileType , tileX, tileY) I can't figure out how to initialize array and load textures into it though in order to do this, without getting errors. Basically I need to draw my map based on numbers I have in a tile map like this int worldMap 1,1,1,1,1,1,1,1,1,1 , 1,1,1,1,1,1,1,1,1,1 , 1,1,1,1,1,1,1,1,1,1 , 1,1,1,3,3,3,1,1,1,1 , 1,1,1,3,3,3,1,1,1,1 , 1,1,1,3,3,3,1,1,1,1 , 1,1,1,1,1,1,1,1,1,1 , 1,1,1,1,1,1,1,1,1,1 , 1,1,1,1,1,1,1,1,1,1 , 1,1,1,1,1,1,1,1,1,1 , I need to draw the map tile based on the numbers in that map... 1 grass 2 dirt 3 water etc.... Still no luck getting the array working.


How to create a generic character entity in Entity System? In the below code is the way I create a character in Entity System. But I think this is the decouple, I'm having hard time decoupling this class. 1st approach public enum CharacterType PLAYER CHARACTER, PC or a character controlled by a player NON PLAYER CHARACTER NPC or a character controlled by a computer it self (artificial intelligence), but notice that it is a friendly character public class Character Player Character can be controlled by the player it self None Player Character is a autonomous and cannot be controlled Player Enemy target a player character Player Allied target a player enemy and friendly to a player character All character is moving CharacterType type CharacterMovement movement or public class PlayerCharacter extends Character public class NonPlayerCharacter extends Character public class Merchant extends NonPlayerCharacter public class Enemy extends Character public class CharacterComponent implements Component public Character character 2nd approach public class PlayerComponent implements Component public static final int IDLE 0 public static final int MOVE UP 1 ... public class NonePlayerComponent implements Component public static final int IDLE 0 public static final int MOVE UP 1 ... public class EnemyPlayerComponent implements Component public static final int IDLE 0 public static final int MOVE UP 1 ... public class AlliedPlayerComponent implements Component public static final int IDLE 0 public static final int MOVE UP 1 ... Noticed in the 2nd approach that it has a redundant data.


What type of networking system should I use With LibGDX on Android? I've been looking for a good way to implement multiplayer in an Android strategy game I'm working on, using LibGDX. What I found The embedded LibGDX networking system Kryonet Google Play Services (I already used this system for a Unity game) The only problem is that I don't know what system I want to use because I see multiple problems in each of these. In LibGDX's networking and Kryonet, how can players connect to each other without having to tell each other their IP (which is not easy for everybody) ? In Google Play Services, I don't know what are the requirement for users. Do the have to have Google Play, or maybe Google installed on their devices? Also, how easy is it to get Google Play Services to interface with LibGDX and Scene2D?


Incrementally processing large number of entitites in an entity component system LibGDX Ashley has a class IntervalIteratingSystem that allows you to process all entities in a particular family every X milliseconds. But if you have a lot of entities to process, it might be a bad idea to do all that at once. For example, if you want to process 10,000 entities once every 10 seconds, you might not actually want to wait 10 seconds, and then process all the entities you'd want to "spread it out" over many frames. Perhaps every 100ms you process 100 entities, cycling through them all. To rephrase I'd like to process a large number of entities but spread out across multiple frames, preferably providing a reasonable guarantee that all entities will processed at least once every X seconds, enabling you to keep track of how much time has passed since that entity was last processed, with a random entity order, all entities are processed an equal number of times. Here are my ideas so far...(some bad, some good) Every time an entity is added to the Engine, add a Group1, Group2, or GroupN component (either randomly or sequentially), and then in my EntitySystem I cycle through the various families based on their Group . Every 10 seconds, add all 10,000 entities to a list, and then every 100ms, drain and process 100 from that list. (Memory intensive, and might fall behind) Every 100ms, iterate over all 10,000 entities, but skip 99 of them randomly (either using a PRNG or by checking their hashcode mod prime). Maintain a list (a copy, really) of all relevant entities inside an EntitySystem using Engine addEntityListener() and then process 1 of the list every 100ms by sequentially stepping through it, and wrapping around when reaching the end. (Uses LibGDX's unordered Array so removals are cheap). Same as 4., but rely on Engine getEntitiesFor and just let Ashley handle ordering and tracking entities instead of keeping a separate list. At the moment, 1 and 5 seem most promising. 1 seems to meet all my requirements, but is a bit pervasive (creating and adding a bunch of components), 5 is less pervasive, but doesn't meet the requirements quite as well ( 2 and 3 mostly). Thoughts? Is there something better than these?


How to remove white background from an image using LibGdx? I am fairly new to game development. I am developing an application(Aquarium) for windows which requires me to animate(move) fishes around the screen and user will be able to add new fishes drawn on paper and scanned into the application, I did some research and decided to use LibGDX so when user scans the image coming to the system has White background which needs to be removed I needed to know how to remove that make it transparent in LibGDX.


libgdx universal tween engine how to control the tweening speed? How can i control the speed of a tweening sprite? Here is the code in create () try tween w Gdx.graphics.getWidth() h Gdx.graphics.getHeight() texture new Texture("nube png by diieguiitoh d4vhyzb.png") texture.setFilter(TextureFilter.Linear, TextureFilter.Linear) sprite1 new Sprite(texture) sprite1.setPosition(50,0.25f h) Tween.registerAccessor(Sprite.class, new SpriteAccessor()) manager1 new TweenManager() Tween.to(sprite1,SpriteAccessor.POSITION X,1000f) tween POSITION X for a duration .target(w 100) final POSITION X .ease(TweenEquations.easeInOutQuad) easing equation .repeat(10,1000f) ten more times .start(manager1) start it startTime TimeUtils.millis() try tween In render() batch.begin() delta (TimeUtils.millis() startTime) 1000 get time delta manager1.update(delta) update sprite1 sprite1.draw(batch) batch.end()


Statemachine to behaviour tree? Background I was able to convert simple statemachines like this... Into a BT looking like this (Notation describtion)... root sequence After another playAnimation name idle sequence walks? Breaks current sequence if false playAnimation name walk sequence runs? playAnimation name run Goal But how do we convert more complex multi layered animation states into a behaviour tree ? How would such a BT look like ? The difficult parts here are transistions between the different states, something i couldnt solve in an BT. Question Is it possible to convert every statemachine into a behaviour tree ? What does the theory says and how does it look like in practice ?


Need help with getting a direction vector between two given points I need to find the angle of rotation from a bullet traveling from point A to point B, like in my attached diagram. I tried searching, but I got a little lost in which exact formula to use. I want to find the direction of a bullet, expressed as a vector with X and Y coordinates.


Navmesh string pulling vs funneling I'm creating a path finder for navmesh. I'm wondering which method should I use after the A has been completed, funneling or string pulling? What are the advantages disadvantages of using them on a triangle based navmesh?


How to reduce the time taken to path find to an unreachable location? I have a 2048x2048 map and if I path find to an unreachable location, it makes the pathfinder go through every node on the map which freezes the thread for 4 seconds. How can I reduce that time? I'm using JPS It's a dynamic map (it changes at runtime)


Tile Based A Pathfinding, but with a bomb I've written a simple A path finding algorithm to quickly find a way through a tile based dungeon in which the tiles contain the information of walls. An example of a dungeon (only 1 path for simplicity) However now I'd like to add a variable amount of "Bombs" to the algorithm which would allow the path finding to ignore 1 wall. However now it doesn't find the best paths anymore, for example with use of only 1 bomb it generates paths like these While the correct shortest path would be this one The problem is that "Closed Nodes" now interfere with possible paths. Any ideas of how to tackle this problem would be greatly appreciated!


How to generate a navmesh from a set of 3D meshes from scratch I've found a great article on how to build a constrained delaunay triangulation that can be used to create a simple navmesh from cutout geometry. However, this does not seem sufficient to generate a high quality navmesh from any arbitrary set of level geometry from scratch. One of the problems is that it only deals with triangles in XZ space. But how should I handle situations where an arbitrary 3D mesh is intersecting another arbitrary 3D mesh? Within their intersection, each triangle would need to retriangulated in some way.


Sample Projects Source for Navigational Meshes Anyone aware of any sample source code that contain Navigational Meshes? I'm aware of recast navigation (which is a little bit too complicated). Written in C . Preferably C but C is ok.


A path finding for road network data structure to represent directivity I have been reading A path finding to apply on a road like network structure. Most of the code I saw is about A on tile based maps. There is a short description at Amit's page here about what I am looking for. My question is about what data structure should I use to define a road network map. I have infromation like, node, cost,etc. But not sure how to represent both one directional and bidirectional roads. In a graph structure, can I mix directed and undirected edges or use two edges to represent that a segment of road can be traversed in both direction. Any good example available? Thank you so much.


A in 2D game. corner pathfinding issue the issue I'm having will be best described with pictures more so than with code, so lets have a look if you will. So all the mobs followed the player and started attacking him, but as soon as 4 spots to the E, S, W, N were taken, mobs 1 and 2 are no longer able to find the path. When mob from E S W N spot dies they can of course find a way to the player. My question therefore is what is the way to implement this so that mobs can get to the player when only corners are free? Diagonal movement is not allowed and i'm using Euclidean distance. I've read this How do I avoid pathfinding characters getting stuck in corners? and other questions, but they dont quite cover what I need here. I'm sorry if this isnt specific enough, happy to clarify.


Grid Pathfinding with known points What is the best way to, in a grid, to find a path (not necessarily shortest) from a start point to an end point (for both of which the coordinates are known)? The grid is approximately 60x60, and has some obstacles in it. The coordinates of the start point, the end point, and all of the obstacles are known and easily accessible. Searches such as Breadth first and A work, however they seem to do an unnecessarily large amount of "searching" when you should already know where you are going.


How to do starcraft pathfinding? I've been trying to figure out how to implement something like the pathfinding in Starcraft 2. I'm not looking for all the sophisticated features like flocking, queueing, etc. In fact I like how in Starcraft 1 the units would interfere with each other. But I do want a path finder better than that used in Starcraft 1. From the Google searches I've done the various answers have something to do with A over a navigation mesh and or dealing with some kind of "visibility graph". But I've gotten somewhat conflicting or unclear answers on what I should do. One thing I read about has something to do with doing A over the vertices of a triangle mesh (the navigation mesh). And then somehow "straightening out the path" which I don't know how to do. But that doesn't guarantee optimality right? Another question I had is how does the starcraft 2 pathfinding deal with the fact that the units are discs with a finite radius and not points when dealing with corners? And how to deal with dynamic obstacles like idle units or even other moving units. I'm looking for some gritty detailed explaination and not the generic super high level overviews that are typical in search results. If it matters I've already looked at Amit s Notes about Path Finding. I've heard of but not read Computational Geometry Algorithms and Applications. And a blog post about a AI navigation presentation at GDC 2011 mentioned that Starcraft 2 uses a constrained delaunay triangulation for a navmesh. Although the blog post mentions Boids steering and "horizon analysis", it doesn't mention exactly how the core pathfinding is done on the navmesh.


Too many neighbors when pathfinding in Sparse Voxel Octree Imagine we have upto 9 or so layers (that is depth), and due to some big colliding platform in the level, one of the empty nodes close to the root have all much smaller nodes as neighbors at one of its faces. If my calculations are not wrong, in the worst case scenario the number of neighbors on a face would be equal to power(2, absolute(depthA depthB) 2). For example, power(2, absolute(8 2) 2) 4096 little neighbors in direction of only one of the faces of the bigger node. I'm implementing a linear tree (just saving all location codes in a set). I know how to find neighbors. I have no idea how to deal with high number of neighbors in cases like this when running A . Both, finding all neighbors and iterating over all of them would take too much time. I have taken a look at the GDC "Getting of the NavMesh by Daniel Brewer", but their example for neighbors of different sizes was only for difference of 1, which would return only 4 neighbors per face.


Basic A star implementation tutorial Possible Duplicate Pseudo code examples of A ? Hey guys Iam making a TD game and now I am stucked in implementing A star algo. I know there are many 3d party softwares but they are difficult to understand and modify. I want to make own for my game. I need a step wise programming tutorial for implementing A OR if someone has basic snippet. I am using unity and c .


Voxel river flow simulation I am making a Voxel game and I'd like to add rivers that can be redirected. So I thought that if a player replaces a river block or digs up a block next to a river block the river would repath itself to the sea. The rivers path would have a direction and a speed in that direction. The rivers path would be determined by these rules If the river can go down in its direction it will and then pick up speed. or if it has a speed under 2 and it can go sideways and down it will and keep its direction. Otherwise it will keep going in its direction until blocked, where it will pick a new direction. If the river can't go anywhere it will fill up the layer its on like a bathtub and go up. Repeat until it reaches the ocean. However I can't figure out how you can know what to fill. The data would be stored in some sort of height map. 1 same level, 0 down a level, 2 up a level For example 222222 211112 211112 211112 211112 222222 I can tell that the 2s completely surround the 1s meaning that all the 1s should get filled with water if the river goes up. But how can a computer tell?


Pathfinding to Get In Attack Range with "Transparent" Tiles Currently I'm using A and a raycasting algorithm to determine the path an entity (Player) should take to get close enough to the enemy (Enemy). The player has an attack range (it's illustrated around the enemy to show how close the player has to get to the enemy in order to attack it). This works pretty well, but as soon as I add tiles that prevent entities from moving from them, but allows them to attack through them (imagine a river). Using my current implementation the player entity takes the purple route to attack the entity, but I want it to take the yellow path. I came up with the following, but this is highly inefficient Mark the tiles around the enemy (cyan circle), which are in line of sight to the enemy (raycasting) as possible destinations Run the pathfinding algorithm to find which one of those destinations is the closest to the player I know A is good for finding a single destination and Dijkstra is better for multiple destinations, but since I already got this working with A I wanted to know if it's possible to achieve this is an efficient manner. Side question how are the tiles where you cannot walk through, but can shoot through called in the industry? I know the wall likes entities are mostly called "solids".


Restrict A pathfinding to overlapping "safe zones" within map I've been bashing my head against this idea for a few days without luck, I'm hoping someone sees something I don't. So I have a 2D map containing walls and obstacles, and I have a unit that navigates through it (A and funnel algorithm). So far so good. Now, for gameplay purposes, I need to limit the movement of this unit to circular safe zones that I can place on the map. Think of them like cell towers, the unit has to stay within range of at least one tower, with the max range dictated by the tower (possibly different for each tower). Effectively, imagine drawing a set of interlocking circles over the map, and the unit must remain within that. Now for the complicated part. The map is a constrained Delaunay triangulation, not a grid, so the triangles that A is using can vary in size and shape. With a grid, I could imagine limiting individual grid cells by circle distances, but in my case these triangles could be larger than any one circle. There could even be cases where the start and end points of a path are within the same triangle, but because of the network of circles, an indirect path would have to be chosen to stay within the circles. The only option I can think of involves adding these circles into the triangulation as additional edges, altering the map. This would mean rebuilding the map triangulation each time a player adds or removes these circles, and would require that I maintain a separate copy of that triangulation per player. And since these circles don't care about map walls, I'd have to alter my triangulation method to allow edge splitting and removal, to prevent overlapping lines from rendering the triangulation invalid. I feel like there has to be another way to do this. I've considered Running A purely on the circles first, then placing that intermediate path on the map and re pathing it to avoid obstacles. Finding all of the circle intersections between the start and end points, and treat those lines as portals that I must pass through, somehow altering the A pathing to prioritize passing through them. Performing a regular path search on the triangulation, but forcing a dead end whenever entering a triangle that is too far from a circle. Then refining that path to conform to the circles themselves. Each of these have issues, or scenarios where they fall apart. Has this been done before? Any input on how this might possibly be achieved would be appreciated. Edit Adding an image to show what I'm trying to accomplish. The red lines show the path that A would generate using just the map triangulation. The green lines show the desired path, taking the circle bounds into account.


Pathfinding over a moving platform I have beens struggling with the following. In the game I am developing with Unity 5 in C , I need to implement basic pathfinding over moving platforms (not with moving platforms). It means, I am not concerned that NPC are able to take moving platforms, I am specifically concerned that the whole pathfinding process should happen on big moving floors. Being that the case, NavMeshes are not an option. Would anyone happen to know of any approach, or have any good tips for that? Thanks in advance for your time.


Map building Tower Defense Before diving too deep into my question, let it be known that I am learning as far as java script goes and figured a simple Tower Defense game would be an excellent way to learn things. So I have found a simple background image with a path drawn on it and my question is how would I go about building a path so that I can animate my objects. Would I have to take the image and overlay a grid system, or can I store the path in some sort of array and have my objects move across it? Here is the background image


Navmesh awkward path generation with string pulling due to "inner" vertices I've identified a problem and a possible solution related to navmesh based pathfinding. Before diving in, I'll preface my post with some questions to keep in mind as you read Is this a known problem that people have solved before? Is there a term for the problem that could help me search for information related to it? Is the solution I came up with an existing idea? If so is there a name for the algorithm or some other search term I could use to find more information? Is there a better solution? If so, please point me to it. For reference, I'm using images from http jceipek.com Olin Coding Tutorials pathing.html navigation meshes and generally following the advice laid out there. tl dr of that blog post is Decompose your walkable area into a navmesh, treating convex polygons as nodes and their borders as edges so that you can perform an A search to get from point A to point B. To translate from "node ids" back to real points, use string pulling. Here's a copy of the example space And an example generated path after performing string pulling So far so good. But I realized this approach generates an awkward path in a situation like this In this situation, a trio of nodes are all adjacent to each other, and so the A will generally choose a path directly from the starting node to the ending node, despite an intuitive understanding that the agent can move in a straight line from A to B which travels through a different polygon. I've been working on a solution to this problem and so far my best idea is to apply a transformation to the nav mesh. My description of this will be a little hazy as I'm making up terminology to describe the approach... Define a shared edge as a line segment that is shared by two convex polygons in the navmesh. Maybe a.k.a. a "portal" for string pulling purposes. Define an inner vertex as a vertex in the navmesh for which all attached line segments are "shared edges". The vertex in the center of the three polygons in the image above is an inner vertex. Identify an inner vertex. Follow its attached shared edges to what I'll call neighbor vertex. (possible improvement If the neighbor vertex is also an inner vertex, recurse to its neighbors until all of the neighbors are non inner.) Remove all shared edges from the navmesh that were traversed in the previous step, forming a new polygon whose border is defined by the neighbor vertices in the previous step. Redefine the edges accordingly (I'll hand wave that) Repeat until no inner vertices remain. The result of this on the example above should result in this And with the same A B path from before, the string pulling should now result in a straight line I believe that as long as the navmesh has no inner vertices, all paths generated with the approach described in the linked blog post should seem "natural" and not have any surprise corners in what seems like open space. Per my questions at the beginning of this post, I'm looking for more information, e.g. has anybody else solved this problem before, is there a better way to do it, and is there even a name term for this problem?


Reducing the number of edges in a pathfinder I've worked out an algorithm for pathfinding in a quite free form terrain (not constrained to grids), with the limitation that it doesn't allow the moving character to rotate. I'll use it for AABBs so that's not a problem, and I'll assume AABBs below. However, one of the steps consists of creating a graph in which the path is to be found, and that's where the problem is it seems to me that the number of graph edges to construct is going to be O(V ) where V is the number of vertices. Yet when looking at a typical graph, it is apparent that many of these edges do not need any consideration at all. So the question is if there is a way to reduce the number of edges. The algorithm goes like this. The input is a traveler, a series of boxes (the maze) and a destination point http www.formauri.es personal pgimeno temp rect4572.png (in this example, the reference point of the traveler is at the bottom right of the rectangle because I made a mistake estimating the MDs by hand sorry about that) Calculate the Minkowski difference of the traveler and each box in the maze http www.formauri.es personal pgimeno temp rect4574.png this reduces the problem to having a point crossing that maze, simplifying analysis. Create the graph 2.1. Each vertex is a corner of one of the boxes in the Minkowski difference. 2.2. For each pair of vertices, there is an edge iff the line between them does not have any point inside one of the boxes. In other words, if there is a direct line of sight between them. Result http www.formauri.es personal pgimeno temp rect4758.png (done by hand I may have forgotten edges) Run a pathfinding algorithm on that graph. http www.formauri.es personal pgimeno temp rect4776.png The path found is directly usable in the original map http www.formauri.es personal pgimeno temp rect5158.png The problem is step 2.2. Is it possible to reduce the number of edges? I'm not aware of any pitfalls in the algorithm, but if you see one, please let me know as well.


How can I implement caching into my Rectangular Symmetry Reduction pathfinding algorithm? I have a working implementation of Rectangular Symmetry Reduction (see here and here for more information on RSR). I'm interested in further improving performance over raw A by implementing caching of paths. My assumptions are as follows We're working on a 4 connect square grid The Destination position is more important than the start position. Because RSR is made possible via contiguous rectangular regions, the fastest path between two points in the same region is likely to be the same (but not always) It's at this point that I get stuck I'm unsure how best to use those assumptions and the information generated by a path calculation to better future path calculations. I've considered storing the path cost from the final waypoint (that is, where the resultant path leaves the first rectangle), but as far as I've been able to consider, that is only useful if I have the path cost from every other potential waypoint on the rectangle's edge so good if you've got a lot of rectangular rooms separated by doors (few open edges), less so if you're pathing around wide open fields with a few scattered rocks (many open edges). Essentially, my intuition is that going that route would potentially necessitate a lot of pathfinding before caching could provide any returns, so I'm looking for someone else's opinion on whether I'm on the right track, or if I'm missing a simpler way of implementing a performance boosting caching algorithm. Thoughts? I'm more than happy to discuss more of what I understand of the algorithm or share specific code if requested.


Path Planning in a chaotic, ever changing environment I've implemented Path Planning a few times, using A on nav meshes, and also Continuum Crowds but now I am trying to plan paths in very chaotic environments. In this environment, new routes and new blockages are created constantly, and chaotically. This is because the environment is fully destructible, and the debris can create new obstacles. In such an environment, nothing can be pre computed. What would be a good way to sense the traversability in such a world? There is no concept of a grid in my world, b.t.w, but I wonder if I should introduce an artificial one for the purpose of planning. But if navigation could be achieved without a grid, that would be much better of course. Note that the navigation is not merely dynamic in the sense that certain transitions get opened closed, but actually chaotic. This stops me from a simple approach of enabling disabling certain edges on the navigation mesh. That approach would be usable if, e.g. a gate gets locked unlocked. But in my case, in a blink of an eye, the routes could be drastically changed where simple mutations of a pre computed mesh are not doable.


Simple Stupid Funnel Algorithm (SSFA) for 3D Navigation tl dr I need an algorithm similar to SSFA except for portals with 4 vertices (or n vertices if an algorithm like that exists). I'm working on a game that requires pathfinding in 3 dimensions. By this I mean agents have full control over their position as opposed to many games where agents only control forward, back, left, right, and need to walk up stairs or ramps to go up and down. To do this I made a "nav mesh" using an octree that checks for collision at each region, and subdivides if there is a collision (until a certain cube size limit). So I now have a graph where each node is a cube with some size based on the octree. Using this I can run the A algorithm for pathfinding on the graph. Unfortunately, just moving towards the center of each node looks bad, and even moving towards the center of each connecting face of the node (the smaller of the two connected node's adjacent faces) looks bad. In the past, I've used the SSFA for path simplification, but it only applies to situations with an edge as a portal, not a face. Is there an algorithm for this, or is there a way to make my pathing look better? Ninja edit I'm already somewhat using steering behaviors, but since the center of nodes can vary wildly, based on the complexity of the octree, it still doesn't look nice.


Moving unit along a computed path I am generating a path using pathfinding.js. This returns a path of node coordinates from a matrix. Example var matrix 0,0,0,0 , 0 are passable, 1 are obstacles 0,1,1,0 , 0,1,1,0 , 0,0,0,0 var path 0,0 , 0,1 , 0,2 , 0,3 , 1,3 etc. I now wish to convert this to path to something like, takeoff(), turnLeft(), forward(4) etc. What this process called, I have had a look at many programming books and guides but they seem to ignore this method or miss it out. I also had a go at it myself but can't figure out the direction of unit that is being moved along the path.


In what instances would you want to use path finding algorithms other than A ? I am familiar with how the common ones technically work (BFS, DFS, Dijkstra, A ) but as far as their realistic benefits I don't quite see the need for them. Considering that, given the right heuristics, A is more performant then why bother with any others?


Pathfinding towards a moving target in 2D Platformer I have an enemy in my 2D platformer that chases the player around the level. I implemented a modified version of A that works with gravity as described here https gamedevelopment.tutsplus.com tutorials how to adapt a pathfinding to a 2d grid based platformer theory cms 24662 But for a moving target I would have to calculate a new path whenever the target moves. Of course I'm going to run the pathfinding on a separate thread and only once a second or something like that, but it's still a waste to calculate the path from scratch. So I found this algorithm for transforming the old path to the new path with the new start and target position called FRA http idm lab.org bib abstracts papers ijcai09b.pdf However the platformer version of A has a kind of 3D grid where nodes with different jump values in the same 2D location has a different z coordinate. Is it possible to use FRA when jump values comes into play? Do I have to recalculate jump values?


What is the difference between Djikstra and flow fields? I understand flow field pathfinding (as illustrated in recent Gas Powered Games titles) consists of 1) computing a vector field covering the map for a given destination, 2) deriving unit directions from their position on that field, and 3) recomputing it at each frame to take dynamic obstacles into account. I was wondering if the very same steps could be used, but by computing the vector field simply with Dijkstra. After all, if you apply Dijkstra in reverse (from the destination), and continue until you've covered the whole map, you end up with a vector field giving the best direction for each unit trying to get to that destination. If you recompute it each frame, don't you end up with the same behavior and efficiency as flow field, only without the math I don't understand?


How to generate a navmesh from a set of 3D meshes from scratch I've found a great article on how to build a constrained delaunay triangulation that can be used to create a simple navmesh from cutout geometry. However, this does not seem sufficient to generate a high quality navmesh from any arbitrary set of level geometry from scratch. One of the problems is that it only deals with triangles in XZ space. But how should I handle situations where an arbitrary 3D mesh is intersecting another arbitrary 3D mesh? Within their intersection, each triangle would need to retriangulated in some way.


Tile walking algorithm for already known set of walkable tile? Suppose I already have a list of tile that specify which tile the character can move to, and these tiles are clustered around the character. If I want to produce a path (maybe not shortest, but just a short path) to the desired tile, how would I construct it with the given list of tiles? I was going to do an A algorithm, however, thinking again, it will complicate my coding process. Therefore, is there a better way to find short path for known list of movable tile?


How should I use Monte Carlo method to simulate some police cars that keep patroling in a tile based map? I have a tile map (isometric) and I have some police cars that they patrol all the time on the map, there is some building and other cars in map too so they are considered as constraints in my shortest path algorithm (below). I use to randomly select some target for each police car and use A algorithm to find the path to the randomly selected destination tile and this cycles over and over. because cars should move all the time! (except those that gamer should control) The problem is police cars routes are correlated and they do not just traverse the area randomly, for instance, they do not usually cover a same area or they do not repeat their own route so my implementation based on some random destination point wasn t a good idea and the result was not satisfying. Take a look at the following picture, it shows how randomly selecting the destinations worked for me, obviously, it is a dumb patroling for sure, even a cockroache could do better! Suddenly, I remembered Monte Carlo Method and I thought it would solve my problem, because it exactly does what I wanted to do, However may be I should use Zobrist Hashing since it is tile base in nature. Does anyone has any idea how should I use this kind of methods? Question in Brief How can I use Zobrist Hashing or Monte Carlo method to set destinations points for my patroling car (like police car)? If anyone knows another way to implement a patrolling method, he she is very welcome to post an answer, I am not sure if Zobrist Hashing is the best and worth to implement. First Edit (added following paragraph) I need to distribute the cars and their destination points in a homogeneous manner. Every kind of solution that get me close to a good pattern could be my answer, of course there is a lot of methods to do so, but I dont have any clue.


Shortest path to a road I have a road network and a vehicle that is current off the roads. I want to find the shortest path to any road. An obvious solution is to run a pathfinding algorithm between the current vehicle location and all the points on the road, but that's hardly scalable. I am curious to know if there is an algorithm out there that I could use to maximize the performance of this operation.


A Pathfinding Gridless With Circles I found that A is an algorithm for grid (or tiled) maps. I want to use it or some alternative of it to my game. The problem is that I have no grid. I have canvas and GameObjects could be at position x 23.91324512, y 131.12334253461 . How would you do this? And another question, I have element with stepSize (concretely called movementSpeed), and getPosition().getX(), getPosition().getY() AND getRadius() which returns the radius of a circle. How would you do A algorithm with radius? Btw I am implementing it in Java, so maybe some Java snippet would be helpful. EDIT As you may suggest me to create a virtual grid, how do I check if I can move to the next node when I have my getRadius() and all the obstacles getRadiuses


Travelling in a 2D grid I have a 2D grid (x,y coordinates) where each cell corresponds to each pixel of the interface that I am working with and I have a point A(x1,y1). Now I need to travel around in the grid, and I wont just move this single point, but would like to move a bunch of points together. Now what do you think is the best figure that I shall move, i.e. a circle with a predefined radius, or a square with a fixed side. Also, once I decide upon the figure, I need to know, what all points are there in the figure, given a specific central point, and work with those points too. I was thinking that a square would be a better idea, since I'll just have to check the if the difference of the coordinates of the point to be checked from the central point is less than side 2. But I've heard that calculations with circle are not bad either. Kindly suggest,


Delaunay triangulation. Where to start? I'm trying to learn procedural generation technique's. Specifically for dungeons. I started off with a 2D array and I generate my rooms fine. Each room contains wall tiles as seen in the screenshot below. Right now I use A to link the rooms together. But this has some paths go straight through other rooms or around rooms. Having done some googling I found this demo which game me the idea of using Delaunay Triangulation to properly connect the rooms without going through already existing connections rooms. But how to apply it to my 2D array setup? My initial thinking is that I should think out side of the box (2d array haha) and grab my rooms and create a complete graph from this and then apply the Delaunay Triangulation. I've never done anything with graphs before. So what I would to know is a) is my thinking correct in creating the graph with all the rooms linked and then to apply the triangulation and b) where should i start? small edit after some more looking around stackoverflow i found this post explaining Graphs more in depth. https stackoverflow.com questions 15306040 generate an adjacency matrix for a weighted graph


Logic to path finding checking I'm a little stuck on the logic to how i use my path finder efficiently in my game. This is basically how the game works Building generates goods "Factory" gt AI transports goods to "Warehouse" on path tiles gt Warehouse receives goods gt AI goes back to Factory. Now im wondering how I use my path finder efficiently so its checking the "Factory" is connected to a warehouse by path. So heres my logic im wondering if it can be improved User places factory down gt game checks path. Result 1 No path found gt Keep checking every frame.. Result 2 Path found gt Store path stop rechecking every frame. The two problems i have is Well checking every frame is going to hurt the game's performance, secondly if I stop rechecking it won't know when a faster route may become available or unavailable Is my logic correct or is there a better method?


How do I get the id of an object that created a point in a path? I'm making a rollercoaster tycoon type game. As the title says, I need to get the id of an object that created a path point. These points are currently greated by the rail pieces. I need this because each rail type (down, up, corners, etc) decides how fast the cart is going to go. The cart follows a path, with points created when a new rail is created. Normally, I would just use instance place, but since the coaster has multiple levels (defined by z), I can't use this because some rails will overlap other. If you have any suggestions, I will be very grateful! For more information just ask and I will respond. Thank you for your time. Here's a screenshot of the game for reference (the blue thing is the cart, the white numbers are the added or subtracted speed for that particular rail type)


Algorithm for waypoint path following? I have a worldmap, with different cities on it. The player can choose a city from a menu, or click on an available cities on the world map, and the toon should walk over there. I want him to follow a predefined path. Lets say our hero is on the city 1. He clicks on city 4. I want him to follow the path to city 2 and from there to city 4. I was handling this easily with arrow movement (left right top bottom) since its a single check. Now I'm not sure how I should do this. Should I loop threw each possible path and check which one leads me to D the fastest ... and if I do how do I avoid running in circle forever with cities 1 5 2 ?


How to fix cutting corner problem in A star pathfinding So this is a problem when doing diagonal jumps (checking diagonal neighbor nodes). In 2d it can be prevented by doing some checks, like if up and right is blocked, don't take up right neighbor for calculations. But in 3d thous check become a bit to much and to tedious.. so if I still want diagonal paths, what could be a good solution?


Detecting if an object is following a path I am attempting to take GPS data and track it on a map and see if it follows a given path. I have the path as a set of points and the GPS data streams in as a similar set of points. I am attempting to track the progression of the current position across the path and I am wondering if there are any well known algorithms for this. I have come up with my own that works ok but it is a complex enough problem that I would like to minimize the amount of re inventing of the wheel that I do. What approach or algorithm would you recommend taking for this problem?


Pathfinding With Speed Based Turning Restrictions I have been working on a path finding project and I m a bit stuck at the moment. I have an object that can increase or decrease speed, but the faster it moves the larger it s turn radius is so a car basically. I ve implemented A with a smoothing algorithm to generate waypoints for the object, however, as you might guess, it doesn t take into account anything with speed and such. Currently, I m moving the object at a set speed along it s forward vector and at each waypoint lerp the direction to the next waypoint. Is there a method or a place to start looking to implement a system to find the best route that s possible by slowing or taking larger turns? At this point I d even settle for a way to tell the object exactly how much it needs to slow down for each turn. Thanks for any help!


What heuristics are used in NavMeshes? What heuristics do programmers use in A pathfinding for NavMeshes? NavMesh Navigation Mesh, its a type of pathfinding that uses meshes instead of waypoints.


Group arrival steering I've got group movement implemented pretty much like this http www.red3d.com cwr steer CrowdPath.html Basically, that's combining path following and separation. It works nicely as long as units are in transit, but arrival does not work very well at all. Right now, units just cease to use the path following component once the "exit" the path, i.e. when their closest point on the path is on or past the end. This leads to those units bumping into each other and also overshooting the point the player clicked. Ideally, I'd have the units arrive scattered around the finish point (and reasonable close to each other), not all clumped up past the finish line. I'd imagine that some kind of arrival steering might work here, but based on other units and a "fuzzy" classification of the end of the path. Is there any proven way to do this?


Path Planning in a chaotic, ever changing environment I've implemented Path Planning a few times, using A on nav meshes, and also Continuum Crowds but now I am trying to plan paths in very chaotic environments. In this environment, new routes and new blockages are created constantly, and chaotically. This is because the environment is fully destructible, and the debris can create new obstacles. In such an environment, nothing can be pre computed. What would be a good way to sense the traversability in such a world? There is no concept of a grid in my world, b.t.w, but I wonder if I should introduce an artificial one for the purpose of planning. But if navigation could be achieved without a grid, that would be much better of course. Note that the navigation is not merely dynamic in the sense that certain transitions get opened closed, but actually chaotic. This stops me from a simple approach of enabling disabling certain edges on the navigation mesh. That approach would be usable if, e.g. a gate gets locked unlocked. But in my case, in a blink of an eye, the routes could be drastically changed where simple mutations of a pre computed mesh are not doable.


Aron Granbergs Unity Pathfinding AI goes back and forth The agent goes back and forth after calculating the path with seeker.StartPath (transform.position,target.transform.position, OnPathComplete) . The gizmo shows the correct path. Please watch this short video to get an impression on what happens. It starts after adding about 100 obstacles during runtime. Is this a known bug or am I doing something wrong? My test case is really simple. I can provide the project if necessary. Link to the Video http screencast.com t 2ww04975l


AI Pathfinding Algorithms I am looking to create a special kind of pathfinding system. At this point, the geometry is still flexible, but this pathfinding is integral to the project. The goals I have are this I will have a number of entities seeking paths. Each entity will have a memory of certain paths. The memory will be based on landmarks. Landmarks will be objects or entities on the map that can be or have been seen by the entity. When an entity generates a path, it's only doing it based on what it can see, and what it has memory of. Anything else has to be guessed, it can't use unknown information. The system has to be able to handle a updating paths for a lot of entities at once, but it never has to find the best path, especially not on the first try. It doesn't need to find a path to it's destination in a single frame, just be able to make progress, and reach the target eventually if possible. Entities might be able to share partial or full path information. I'm thinking this is best served by some modified D algorithm, but I was wondering if anyone had any other suggestions for something to do this, or challenges that I'd expect to face. One thing I'm cognizant of for instance is that if I'm using landmarks to confirm the path, that I'll be able to quickly look up nearby landmarks. If I have thousands of landmarks in a list and need to iterate through them and calculate distance to the player this is going to cause trouble. If I'm going to define regions, like a convex hull, I might be able to share that calculation across entities when they need it since I might be able to say anyone inside this poly should be able to see everything within this poly.


Pathfinding assistance Here's a quick image I've generated a navmesh for my game that shows how an AI can get to each of its possible neighboring tiles in a map. (I followed some gamasutra article as reference, I'll paste a link if I can find it again). You can see that it calculates all possible jump, fall, and walking connections between points. Now that I have this, I've been researching how to actually use it. I understand that A is generally the algorithm that people use but I haven't been able to find a resource for adapting it to a non grid based dataset. Any articles that you know of or pseudocode would be awesome )


Pathfinding with lock and key? I'm working on a game with maps that resemble lock and key puzzles. The AI needs to navigate to a goal that may be behind a locked red door, but the red key may be behind a locked blue door, and so on... This puzzle is similar to a Zelda style dungeon, like this picture To get to the Goal, you must defeat the Boss, which requires going over the pit, which requires collecting the Feather, which requires collecting the Key Zelda dungeons tend to be linear. However, I need to solve the problem in the general case. So The goal could require one of a set of keys. So maybe you need to get either the red key or the blue key. Or there could be an unlocked door the long way around! There could be multiple doors and keys of a kind. E.g. there could be multiple red keys in the map, and collecting one will grant access to all the red doors. The goal may be inaccessible because the right keys are behind locked doors How would I perform pathfinding on such a map? What would the search graph look like? Note the last point about detecting inaccessible goals is important A , for example, is extremely inefficient if the goal is inaccessible. I would like to deal with this efficiently. Assume that the AI knows where everything is on the map.