Converting DirectX 9 code to DirectX 10 Preface I purchased Programming an RTS in DirectX recently, and I know the code uses DirectX 9, but it has fantastic reviews and is apparently one of the best books you can get on beginning DirectX. Question To my understanding, DirectX is just a means of displaying graphics to the scene. I will still have to code any games in C using game logic code, input, etc. Was I naive in thinking I could read the book with the MSDN tutorial site open for DirectX 10, and convert all of the samples to DirectX 10, or is that gonna be extremely difficult for me to do? Also, is DirectX 9 still relevant, or would it really behoove me to go about converting to DX 10? Thanks!


New to Game Development, need advice Possible Duplicate What are some good resources for getting a beginner started in developing games? I'm a CS student, having plenty enough knowledge in programming, and general algorithms. What is your suggestion in game developing? How to start? Thanks a lot!


Is game software design the same as non game software design? Is the software design process for a game similar to a non game? Do developers create UML diagrams? I ask because of the iterative nature of game development, I wonder if creating a UML diagram would just be a waste.


Building a unified interface for a swap chain in both DirectX 12 and Vulkan Most objects in DirectX 12 have natural analogues in Vulkan, e.g. VkInstance IDXGIFactory VkPhysicalDevice IDXGIAdapter VkDevice ID3D12Device VkQueue ID3D12CommandQueue VkCommandBuffer ID3D12CommandList However, when it comes to the swap chain, it's not clear how the entries in VkSwapchainCreateInfoKHR correspond to entries in DXGI SWAP CHAIN DESC1. Clearly, there is not always a 1 1 correspondence, but I would really like to know how I can implement a unified interface for both.


How to profile CPU and GPU performance if I have a monster PC? I'm going to upgrade my PC soon. I'm worried that I will no longer spot performance losses in my game because of the better specs. I can check memory usage easily, but how do I check and debug CPU and GPU usage? I used to rely on the framerate, but I guess that it is not accurate.


Finding other programmers to help on a project As a semi FAQ question attempt Where can you find people to work with you on a project? Particularly programmers. One thing that is obvious is that all programmers have a project (or twenty), and the chances of a programmer just hanging around looking for something to do is a lot less likely than if it were an artist needed on the team. So, where do you post? Where do you search and follow people around until it looks like they are a viable team member? Is it really difficult to assemble a team that are not close friends or chat buddies? Are there sites with this sort of posting? To clarify I am referring to a team. Example 1 I am making gameEngineOfAwesomeness. I need help. Example 2 I am 70 complete on this game, and i need help. Example 3 I have an open source project idea, with a prototype. I need help. It doesn't necessarily mean open source, just programmers who can work with me on something (and where to find them ))


Making game constants tables available to game logic classes routines in a modular manner Suppose I have a game where there are several predefined constants and charts (a XP chart, cost of goods and so on). Those could be defined at runtime, or load from files at start up. The question is how should those logic routines access the constants and charts? For example, I could try using global variables, but that cause all classes relying on the variables to be tightly coupled with them.


Recursive dungeon maps as represented by an elastic 2d array I came up with a method for recursively generating simple dungeon maps by starting with one room and recursively connecting new adjacent rooms randomly to it. Maps are represented as two dimensional arrays where each cell contains a value of 0 15. 0 represents no room while each direction is represented by north 1, east 2, south 4, west 8. I wanted to start with a single non room ( 0 ) and then expand the 2d array as necessary to fit the generated map. The difficulty I face with this tree like recursion is that if the arrays have to be unshifted to add rows and columns to the left and top of the map, I have to adjust the current position of the function, what row and column it is at. This makes it so that separate branches are not aware of array index adjustments from other branches, only their child functions will know because they have the adjusted position passed to them as their row and column arguments. Is there a way to do this? I tried storing row and column offset values outside of the recursion, but it did not work for some reason.


Should I use Game Engines to learn to make 3D games? HI i am a software engineering student in his second last year. I am proficient with C,C ,C and java programming languages, and being a student of engineering I have studied calculus, vectors etc in both 2D and 3D amp various other mathematical, probability and statistical topics. I have made several 2D games, my most recent being a Super Mario like game with side scrolling and multiple levels. Due to my these small game projects,i have become really interested in making games. So now i want to move ahead to learn to make games in 3D. Now I know that there are several game engines available which can take care of rendering details and other "low level" stuff for me... My Question is 1) Is it a good idea to learn to program everything yourself, from making 3D shapes, terrains (using polygons meshes) etc, to programming mechanism for collision detection, lighting etc, considering my motive is to learn how to make games in 3D (but am not too eager to get into the game industry quickly, want to build a solid foundation first) Or could I do without these details amp work on the abstraction level which the game engines (like UDK) provide ?? 3) If I should try to develop from scratch, then can anybody suggest which API to use Direct3D or OpenGL?? (which i would be more comfortable with, in light of my above mentioned skills) amp can anybody also give me references to some good books, reading materials, tutorials, etc to get me started?? (I wouldn't mind theory as long as it helps me make a sound foundation) Many Thanx in advance (for even reading my question, i know it's lengthy... but i need a DETAILED answer... D D )


Time loop ticking architecture Say I build a snooker game, where balls need to jitter around. Balls belong to a class (ball class), where all the ball functions are defined. In the animation, time evolves by a clock ticking within a time loop. I wonder if the clock function time loop should be optimally defined in the main program or the class file? If defined in the class, the advantage is that all functions regarding ball movements, collisions etc, which take time to happen, can be put in the class, without worrying about the time loop the disadvantage is that time will tick for every ball separately, which obviously looks bad.


How should bots be recognised in a game? I'm interested in how bots are usually written. Here's my situation I plan to make an online 2D mecha game in HTML5, and the server side will be done with node. It is intended to be multiplayer, but I also want to make bots in case there aren't enough players. How does my game logic see them, as players or as bots? Is there a standard by which I should make them? Also, any general tips and hints will be OK.


Game programming course materials What should it include? I am tasked to create the course materials for a game programming class, and I d like your opinion on what aspects and areas of game programming, such as game state management, game object storing or simple AI, should I include in it? The course is intented to be the first step into game programming for students with novice skills in programming. There will be mathematics as well, but I found that there are multiple questions, with good answers, on that subject already.


Looking for an elegant way to represent fixed parts of a randomly generated level map I'm coding from scratch a small experimental game on a medium sized random rectangular square tile map. (Say, a map of a dungeon.) There are several types of tiles (for example floor, wall, monster, boss, treasure, player etc.). There are no extra information stored in the map tiles, just tile type. Most parts of map are randomly generated. However there are several features that are to appear on every generated map in pre set places. Say, walls around the dungeon, boss locations, player spawn point and the treasure. Note Since the game is small, coded for fun, and the only game designer is a programmer (that is, me myself), I do not plan to spend resources on coding a level editor or supporting an existing one. Also, I do not plan to support existing tile map libraries as I want to dig into some of the related coding problems myself (see above about fun), but I be happy happily to look at relevant existing code as a reference. When I look at my map generation code, I find it rather ugly. Is there an elegant way to deal with the problem? If that matters, I'm writing this game in JavaScript, but I will be happy to see a relevant reference in any programming language. Here is a partial pseudocode to illustrate how my current tile generator solution looks like this.init function(w, h) this.w w this.h h this.tile presets var mid h Math.floor(h 2) var quarter w Math.floor(w 4) Here is the part I don't like a set of generator rules this.preset col (0, Tile.GRASS) this.preset tile (0, mid h, Tile.FLOOR) this.preset col (1, Tile.GRASS) this.preset tile (1, mid h, Tile.FLOOR) this.preset col (2, Tile.WALL) this.preset tile (2, mid h, Tile.FLOOR) this.preset tile (2, mid h, Tile.PLAYER) this.preset tile (1 quarter w, mid h, Tile.BOSS) this.preset tile (2 quarter w, mid h, Tile.BOSS) this.preset tile (3 quarter w, mid h , Tile.TREASURE) this.preset col (w 1, Tile.WALL) Implementation details that may help to understand the code above this.tile function(x, y) var preset this.tile presets x y this.w if (preset ! undefined) return preset return this.random tile () this.preset tile function(x, y, tile) this.tile presets x y this.w tile this.preset col function(x, tile) for (var y 0 y lt this.h y) this.preset tile (x, y, tile) Note that I shown a rather simple set of generator rules above. Actual thing is several times longer. I hate that the code looks imperative and it is hard to figure out what is going on from the first glance. I think that declarative approach could help. But so far I can't figure out a good solution. Any clues?


How could you parallelise a 2D boids simulation How could you program a 2D boids simulation in such a way that it could use processing power from different sources (clusters, gpu). In the above example, the non coloured particles move around until they cluster (yellow) and stop moving. The problem is that all the entities could potentially interact with each other although an entity in the top left is unlikely to interact with one in the bottom right. If the domain was split into different segments, it may speed the whole thing up, But if an entity wanted to cross into another segment there may be problems. At the moment this simulation works with 5000 entities with a good frame rate, I would like to try this with millions if possible. Would it be possible to use quad trees to further optimise this? Any other suggestions?


Doesn't multiple inheritance solve all problems that entity systems do? The question is pretty self explaining doesn't multiple inheritance solve all the problems that entity systems also solve? I just remembered a term called "multiple inheritance", and that seems to solve a lot of bloating problems that classical inheritance imposed.


Time critical events based on framerate Problem Description Basically, I've made a "programming game" in which I've made my own scripting language. It is a completely standard Lunar Lander game, though instead of directly controlling the lander using keyboard input, it instead fires a sequence of commands you have provided through the scripting language I made. This all works, and I've hit a critical problem. So essentially, using the scripting language, you specify something like After 5 seconds, activate thrust for 10 seconds, and then after 2 seconds, rotate the lander for 4 seconds. The goal is then to chain together a sequence of commands which will get you to land the lander safely. Of course, this comes with one problem. If you repeat the sequence of commands, each command will have to be fired at exactly the same spot in the level, that is, after x amount of seconds, but also with the lander being in the exact same spot. If you did not use timer based movement, sure you could indicate that a command should activate after 5 seconds, but the lander moving at 60 FPS would have moved way further than a lander moving at 30 FPS. Why of course, I thought I would simple just make the lander use timer based movement so it is independent of FPS (I am using the very standard approach of taking the amount of time passed last frame, and multiplying it to a constant move speed). Then I would count seconds using the system clock. So the after x amount of seconds, the lander would be in the same spot in the level when the command activates. Unfortunately, this approach do not work. Every time I run a sequence of commands, they will be activated with, sometimes very slight, variations, making it impossible to actually get a consistent and reliable path for the lander. My Question So my question is, am I tackling this problem a completely wrong way? What exactly do you do when it is absolutely critical that timed events defined by the user will activate at exactly the same time and spot in a level? I seem to be quite stuck with this question.


Computer Games Technolgy or Software Engineering? I'm in the last year of my college and going to university next year. Could you tell me what the difference between Software Engineering and Computer Games Technology is? I know a bit of both but don't know the actual difference. I'm kind off in a dilemma between these two. I want to be a programmer, I'd love to go into gaming but I heard getting a job within a computer games company is really hard.


When or why would someone use a programming language (Swift, Java, C , Rust etc...) over an engine like Unity? Everytime I've read about people asking whether they should write their game in C or Unity, Unity is usually the default answer, unless they want to go through the hassle of creating an engine by themselves when Unity already does everything for you. If that's the case is there ever a case where writing a game in C , Java, Rust etc... is better than using Unity? If so what are these cases?


Deep copying or cloning in actionscript 3 I would like to make a mirror reflection of an entity in Flashpunk. So I would like to copy a spritemap from one Entity to another (reflectionEntity). If i use something like this reflectionEntity.sprite otherEntity.sprite reflectionEntity.sprite.scaleY 1 to reflect then the graphic of the original entity is also scaled. Is there a simple way out of this? I have been searching for the solution for more than an hour and have not found a suitable one.


What programming language were PS1 games written in? Is there any common language that is used to create Play Station 1 Games? Or how can I find out what programming language is used for one of those games?


What's the difference between a "Gameplay Programmer" and a "Gameplay Engineer?" I was reading some job descriptions from some AAA developers in the gaming industry, and I noticed there were jobs for "Gameplay Programmers" as well as "Gameplay Engineers." Are those the same thing? Do they do the same thing?


Random numbers inside instance (Game Maker) I've recently run into a weird problem. When I create instances through with(instance create) ... , I can always randomize their variables individually (inside ... ). However, when I try running randomize() random(...) inside their object (in one of the events), they are all synced. Please tell me this isn't a major Game Maker flaw and, most importantly, how do I fix this. Thank you!


What are some ways to separate game logic from animations and the draw loop? I have only previously made flash games, using MovieClips and such to separate out my animations from my game logic. Now I am getting into trying my hand at making a game for Android, but the game programming theory around separating these things still confuses me. I come from a background of developing non game web applications so I am versed in more MVC like patterns and am stuck in that mindset as I approach game programming. I want to do things like abstract my game by having, for example, a game board class that contains the data for a grid of tiles with instances of a tile class that each contain properties. I can give my draw loop access to this and have it draw the game board based on the properties of each tile on the game board, but I don't understand where exactly animation should go. As far as I can tell, animation sort of sits between the abstracted game logic (model) and the draw loop (view). With my MVC mindset, it's frustrating trying to decide where animation is actually supposed to go. It would have quite a bit of data associated with it like a model, but seemingly needs to be very closely coupled with the draw loop in order to have things like frame independent animation. How can I break out of this mindset and start thinking about patterns that make more sense for games?


How should I handle functions, where two classes have equal use? I'm working on a few features for a strategy engine I'm making. I'm trying to figure out the best spots to separate the components, as either option will provide the same amount of coupling, with the same effectiveness. For example, all players have a Damage component, a Player component, and a HealthBar component abstract class Damage protected abstract void sendDamage(Player targetPlayer, int rawDamage) public abstract int calculateRawDamage(Attack attackUsed) public abstract void receiveDamage(int rawDamage) class Player List lt Armor gt equippedArmor List lt Buffs gt currentBuffs public Damage damageComponent public List lt HealthBars gt healthBarComponents abstract class HealthBar can be inherited for mana or health bar protected Color color public float percent 0.0 1.0 When a player receives damage, I need to show a red number floating up from their head, indicating the amount of damage. This can either be implemented in HealthBar, or in Damage. It fits damage better, but then healing works in the same way, and wouldn't be called from damage. I could abstract damage into something like ChangeValue, which would change mana, health, etc in any direction, or I could use the abstract HealthBar class to show this number being changed. I'm trying to think of a general rule that would solve this and other problems, where two classes use the same function equally. This is an oversimplified version of my classes, but it makes more sense this way. How should I handle functions, where two classes have equal use?


Entity Component System based engine Note I'm programming this in Javascript, but it should be language agnostic in the most part. I am thinking about converting my engine to an ECS based one. I get the basic idea (note this is wrong, see my answer) Entities are game objects. Components are bits of functionality (reactToInput()) or state (position) which can get "glued" to entities. Systems have a list of entities they manage and update. But, I'm not quite sure that I get the implementation and some details... Question can a system operate on different kinds of entities? I usually give the example of a class called Scene in my engine, and it will serve this purpose now, as well. A scene is a container of all objects that can be rendered, updated, affect the rendering (lights), and maybe, in future, even 2DSoundEmitter objects. It has a high level interface so the user doesn't need to worry about the type of the object he's scene.add()ing, and all that kind of stuff. I realize that the Scene could be a system. It takes in entities, stores them, and then it can call their update methods, and maybe even do some state changes. But, there is a problem as I described above, the Scene can be fed different types of objects! What should I do in, say, a situation where a scene has both renderable objects ("drawables") and lights in it? Should I make it type check entities before interacting? Or, should I solve it at an even lower level make a LightSource component which can be added to any object, and the light would just be an entity with LightSource and Position components. Is that acceptable? Also, is it a good practice to still use conventional inheritance and traditional classes? For example, I just can't figure out what would my Renderer be! It's not a system, as its only function is to take in a camera and a scene, render everything and apply effects (such as shadows). It also manages the context, the width and the height of the game, makes translations... But it's still not a system! Edit could you maybe link any resources you found on the ECS? I'm having trouble finding good ones.


What exactly is a 'set of states'? Whilst looking into game oriented applications of programming patterns I discovered a question on this site which suggests that a 'set of states' is superior to a 'stack of states' but does not clarify how a 'set of states' would be applied. A stack of states is simple enough to comprehend the state on the top is the active state. But what exactly is a set of states? A set as I understand it is merely a collection of unique objects (i.e. there are no duplicates). Presumably all the states in the set are currently active. But sets are unordered, so how does one maintain order in an unordered collection? An ordered set could be used, but that then brings the question of why use a sorted set and not a list what benefit does the uniqueness bring? I'm just not sure I can imagine how such a thing would be implemented or what benefits it would bring. (Presumably the former issue is causing the latter). So what exactly is a 'set of states'? (In the context of game design programming).


Visual Programming tool for creating game quests I've found a question for visual script editing software tool for creating game behavior logic, but I am looking for something more flexible. I would like to configure the tool to make it produce code that I need. I use Lua for creating quests in my mmorpg game, but every time there is need of creating a new quest I feel like writing the same code all the time. I'd like to allow my co workers to do this job in some easy way. The easiest way I can think of would be some sort of making graphs that would represent the quest, and fill all the nodes with different if statements and game texts or procedures like spawning mobs. Is there any tool that I could use for this purpose?


Benefits of implementing systems like classes instead of just functions In an Entity System I am making, there is a central class called World, which stores all component instances. It's a dictionary of arrays, and entity ids are indexes for the arrays. To access a component of an entity with id 3 you would do this world.storage "ComponentType" 3 . So, each loop of the game, these arrays would be fed to their respected systems ( movement(world.storage "Position" , world.storage "Velocity" ) ). Now, I don't see why systems couldn't be implemented just as functions, as I showed. What optimizations can be made by using classes with data and methods (caching)? Also, these systems would need to iterate over all the entities that exist, doesn't this make entity frameworks much slower than regular inheritance based engines? Why do some people "register" systems to the World class?


What are the most commonly used programming languages? When I took my Java courses a year ago, I was told that Java is used mostly in the overseas gaming companies while C is used here in the US. What languages should I focus on learning in depth?


What are good games to "earn your wings" with? I believe that in order to become a good game developer, you need to make games. From a programmer's perspective, what are some good entry level games to get your hands dirty? What skills and challenges do each of these games teach you?


Problems with instaling SFML I've followed the instructions on installing SFML on the website to the letter. But, I get this when I try to build the sample program on the same page using Code Blocks. C Users nic Desktop sfmltest.o sfmltest.cxx undefined reference to imp ZN2sf6StringC1EPKcRKSt6locale' ... Build failed 20 error(s), 0 warning(s) (0 minute(s), 0 second(s)) I get 20 error messages, which are all similar to the one given above. SFML worked like a charm on my ubuntu 14.04 amd64 install, but it simply does not work on Windows. I am using SFML 2.1 (the GCC 4.7 TDM (SJLJ) 64 bits package as the other ones did not work) on a Windows 7 x64 installation with MinGW (gcc 4.8.1). How can I make SFML work on Windows? edit I'm not sure if I have to copy paste all the SFML dlls to the working directory. Should I do this? edit2 c ping the dlls does not help.


Display a Message Box over a Full Screen DirectX application In our custom assertion handler, I'd like to display a message box asking to see whether or not this failure can be ignored. However, when our DirectX game is full screen, I can't get the MessageBox function to display above the full screen. Note The first parameter to MessageBox is the the HWND used to create the device, and it still does not work. Is this even possible?


How to setup a client to work with a remote server or a local included server? I'm working on a Networked multiplayer game, but while developing and for testing I want to set up a local server that acts like the multiplayer server. My thought is to approach the server as a proxy setup. Creating a class that the client sees and essentially allowing it to either load the server code in itself or to use a networking layer. Is this a good approach? Are there other approaches to look into? What pitfalls should I be watching for? Update A bit more specifically I need to do this because I am targeting the Ouya and I can't guarantee a network connection, or even a spare machine to run the server on. And inside Android it is more difficult to setup and launch a service rather than include my server code right into a client build.


Best solution for "level string"? I have a game that generates a random level map at the start of the level. I want to implement some way to save and load the level. I was thinking maybe XML would be a good option for saving all the variable, then it would be easy for me to build something that can parse that XML and generate the exact same level. But XML is probably overkill for my needs. I remember back in the day with the old Sega console that didn't have the ability to save your game (I think the Worms game did it too), that they would give you a bunch of character that you could write down. If you punched in that string later on, it would load the exact level. Would a "level string" be a good option? Would it be some kind of "base60" conversion? How would I implement this?


Creating VR Headset Video So I have a video stream of known resolution and I have a VR headset via HDMI at a known resolution. Is there an existing library to create the slight fisheye and side by side layout for these single screen headsets? (It's a custom build, so no hardware locked API please) Target Win 7 8 10


How to manage in game factions, alliances, federations, etc So this question is code or engine agnostic but, I m looking for ideas on how a game can keep track of a pre determined number of factions or alliances. For example, say I made a space game that has 2 major and 3 minor federations of planets. A planet may join or leave a federation, but the federation itself may have an alliance or be at war with another (actually, to keep it simpler, I think all these changes will solely be reliant on the player s actions). However, I would also like to keep track of such diplomatic endeavours on the individual level as well. Say the player has joined one federation that is at war with another. If the player should encounter another ship of the opposing federation, that ship becomes hostile. On the other side, two ships have an alliance, they might help one another. What is the best way to keep track of all this? One way I was thinking was creating a manager that holds all the Federation classes (which hold the status it holds with all other federations say less than 0 and the federations are at war more than x amount, there s an alliance). Meanwhile, each player ship holds similar data in its class, along with its current alliance to whatever federation. Is my thinking logical in this or are there better ways of managing such things? Many thanks.


Where does the game code fit into the engine? I was wondering if somebody could tell me how the game and the game engine fit into game development. What I specifically mean is, the game engine does not actually contain a game. Do game developers build an engine, then create a new class that inherits from the engine, which becomes the game? For example, class ShooterGame public Engine I'm not sure about where the game code fits into the engine.


Why are there fewer glitches in current day games? I remember that almost every single game in the early 2000s had at least a few amusing glitches, mostly related to animations, that often produced funny situations. I also remember that game magazines used to dedicate a section with the funniest screenshots people sent in. As an example, I was just playing Far Cry from 2004 and out of nowhere, whenever I killed some bad guy, instead of dropping to the ground they'd start playing the running animation. This was getting me confused since I was trying to shoot them down from a large distance and didn't understand why they weren't dying. I've rarely seen stuff like this in current day games. Was there some change in the technique used to develop games that would make these programmer mistakes less likely? P.S. I'm not talking about RPGs and other inherently complex genres. I'm talking about games like Far Cry shooters like Battlefield 3, Modern Warfare 3, even Mass Effect. I've seen plenty of glitches in games like The Witcher 2, Skyrim, etc.


Effects for Programmers Does anyone have any good resources for creating special effects, aimed at programmers. I'm not specifically interested in particle effects, but broader things like Fullscreen effects, blur, depth of field, damage Explosions, shockwaves Weapons, lasers, projectile Environment light "glows" and beams, water, bubbles, dust etc I'm interested in these things from a technical perspective rather than an artistic one. EDIT To clarify, I'm not interested in the low level details like "a method for doing depth peeling on SPUs" or "fast particle rendering with vertex textures", I'm interested in how people have combined various techniques into a recipe to show a special effect for the game. For example when rendering a "space" explosion Draw opaque bright sphere at center. Draw alpha'd shockwave around a random axis. Expand sphere and decrease alpha. Expand shockwave and rotate UVs. Spawn particles showering randomly from center. Wobble camera when shockwave reaches viewer position.


What are windows used for? I have a very general question In games, what use does the programming concept of a window have? Or, in other words, why do some game dev libraries offer interfaces through which to create multiple windows? mdash Why would you need more than one windows in a game? Are multiple windows used as different views states of the game? (I.e. in game, main menu, pause menu, etc.)


Programmatically drawing a "pencil" line or curve If you look closely (scan it on a computer and zoon in) at a carbon pencil line you can see that there are differing shades of gray. I tried looking on the Internet for any kind of algorithm or statistical model for how that gray would be drawn programatically. Does anyone have information on this? Thanks a lot!! I want to make drawings on a computer that look they were drawn with a pencil.


coloring box2d body in LibGDX I want to color polygon of box2d in LibGDX. Found below useful class for that. http libgdx.badlogicgames.com nightlies docs api com badlogic gdx graphics glutils ShapeRenderer.html But, it is not coloring the body instead making colored shapes. I want colored bodies having all the property like gravity, restitution etc. In brief, I want to make colored ball and surface.And i don't want to attach sprite on bodies. Want just fill color in bodies. Need some guidance????


What scaling system to use in Box2d? I'm worried about this Caution box from the Box2d manual Box2D is tuned for MKS units. Keep the size of moving objects roughly between 0.1 and 10 meters. You'll need to use some scaling system when you render your environment and actors. The Box2D testbed does this by using an OpenGL viewport transform. DO NOT USE PIXELS. I don't want to use OpenGL since I know nothing about it. I'm using SFML to render my game.


Is it a good idea to use box2d to control sprite movement in a 2D game? I'm trying to use Box2D to control sprite movement.Some burning issues are these 1.When I trying to move the sprite on a slope or a lean barrier. The sprite will move off the slope which is not what I want. 2.ALternatively, I could use setPosition or CCAction which provides by cocos2d x to move the sprite and update the body position use SetTransform. But the body will lost it's physical limitation, it will passthrough other body. Thanks for your time, if you guys got any solution?


Box2d How to connect distance joint to the ground? I have a rectangular fixed size world. I want to connect a body inside it to any place(near that body) in the world with a b2DistanceJoint. Do I need to create a large static body with the size of the world that can't collide with anything? Or is there a better method? Will it slow down simulation speed if I have around 300 bodies moving on the surface of this static body?


Rotate Body From Corner I want to ask that how to rotate body from corner? movableBeam.getBeamBody().setTransform(movableBeam.getBeamBody().getPosition(), angle) The above line of code rotate the beam from center that I want rotate from one of the conner. Any member please help me. EDIT float beamCenterX movableBeam.getX() movableBeam.getWidth() 2f float beamCenterY movableBeam.getY() movableBeam.getHeight() 2f float cornerOffsetX movableBeam.getX() beamCenterX float cornerOffsetY movableBeam.getY() beamCenterY float bodyAngle (float) Math.atan2(cornerOffsetY, cornerOffsetX) float newAngle imageAngle bodyAngle float newCornerOffsetX (float) Math.cos(Math .toDegrees(newAngle)) float newCornerOffsetY (float) Math.sin(Math .toDegrees(newAngle)) cornerOffsetX movableBeam.getX() movableBeam.getWidth() 2f cornerOffsetY movableBeam.getY() movableBeam.getHeight() 2f Vector2 postion new Vector2( (newCornerOffsetX cornerOffsetX movableBeam.getX()) PhysicsConstants.PIXEL TO METER RATIO DEFAULT, (newCornerOffsetY cornerOffsetY movableBeam.getY()) PhysicsConstants.PIXEL TO METER RATIO DEFAULT) movableBeam.getBeamBody().setTransform(postion, newAngle)


What is inertia in a physics engine? Inertia seems to be useful in a physics engine, so useful that even in Box2DLite, a demo of Box2D it hasn't been omitted. See this Body class from Box2DLite struct Body Body() void Set(const Vec2 amp w, float m) void AddForce(const Vec2 amp f) force f Vec2 position float rotation Vec2 velocity float angularVelocity Vec2 force float torque Vec2 width float friction float mass, invMass float I, invI inertia and reverse inertia In the implementation of the class, inertia is set as the mass multipled by something I mass (width.x width.x width.y width.y) 12.0f invI 1.0f I What does this formula means ? I understood from wikipedia that Inertia is how much something doesn't want to move but there's not much formulas in this article. Why is it useful in a physics engine ? How is it used in the context of a collision ? Is it compared to other bodies ?


How to keep the value of angle between 0 and PI in box2d In box2d, if i rotate an object multiple times in clockwise or anti clockwise direction, the value of angle ( body.getAngle() ) keeps on increasing. Like at start it is at 0 radians, then 1.57(90 deg), after complete roatation 6.28, then after second rotation 2 6.28 . If a player keeps on rotating for too much time, angle value becomes really big.And for multiplayer games, sending big values uses more bytes. How can i keep the value between 0 to 3.14.Is there any solution in box2d Or Is it a good way of sending Sin(angle) to keep the value between 1 and 1 and doing reverse of sin at client side.


How to make box2d bodies block each other but not push each other? I want to use box2D to create a movement system for an RTS game. How can I make bodies block the movement of other bodies while preventing these bodies from pushing each other?


How to simulate a water splash effect? I need to achieve the effect of a ball falling down into a pool then splashing in the water. At first, I made a sensor to detect the collision between the ball and the water and then show the sprite of the spray. But it's hard to change the sprite according to the velocity of the ball and the angle between the ball and pool. So, I want to simulate the physical model of the water. Now, what I can do is to add a particle system using Cocos2D to show the still water and add physical model to each particle. But, I don't think it is a good solution. Any other I can do it? Waiting for you help.


How to apply impulse to a body to make it fly away? I'm playing around with jbox2d and can't really make a body "fly away" as if from an explosion. From what I have found on the net, making the body fly away from the world center (0,0), should have been something like that b.applyLinearImpulse( new Vec2(0,0) , b.getPosition() ) But really it just doesn't do anything, any idea why? Also how do I change the strength of the impulse, like if it want to make it fly skyhigh or just move a bit?


How to simulate feather fall in box2d? I am working with AndEngine with Box2d extension, but general answer or a concept idea will be appreciated too. I have feather like objects in a 2D side view world that I want to be part of the physics simulation. I am using linear damping to make the "feather" fall slowly. This might not be a good idea, maybe I should rather apply force in each update, but nevertheless, this works and it makes the object look "light" and it feels like there is air with resistance. Now how can I make the objects actually look like feathers falling through air? Specifically I am looking for two types of objects Long with low density, that should move down in a slow swinging motion and square objects that would just randomly change trajectory. It would be great if this could be one simulation and length would be a parameter the longer the object is, the more it would swing. Right now I want to simulate feathers, leaves and snowflakes in a cartoon world.


Problem with sensor in box2d I have two bodies one green static sensor (spikes) and one orange dynamic body (brick). I have bullet and it's a dynamic body too, but with bullet flag set. My problem is that when the bullet is moving left to right, it sometimes hits the orange brick instead of the spikes and it flies away. There is code to remove the bullet when it hits spikes. How can I make sure it hits the spikes first?


Dynamic body in Box2D with fixed position I need to fix the dynamic body position so that it would not rotate and would not move even if there are other forces, collisions and so on. Let me first explain why I need this. I have a dynamic body which is the game character. There are non moving objects that the game character should land on and get some energy as long the character is in contact with those bodies. As these bodies are non moving it would be natural to make them Static or Kinematic. But in my case I cannot do that, as far as there is another Kinematic body with which all the game items should be collided and on EndCollision event those items should be removed. But in Box2D static and kinematic bodies don't collided with each other. So I have to make my game item on which the character should land Dynamic but still should be sure that it will not move. How should I do this?


GetContactList stops reporting collisions on welded bodies I have some strange problem with my game which uses Box2D as physics engine and I'm out of ideas on what I can do to solve it. My game is a class assignment where I need to build a simple game where the main character moves in a 2D environment while square blocks comes from below him. Each time a collision occurs, that block is attached to the character using a weld joint, when three blocks of the same colors are together, they annihilate themselves(an effect similar to Bejeweled). I'm using a recursive function to iterate through all the attached blocks of a given block to see if there are enough blocks for them to be deleted. I'm using GetContactList function to iterate through the list of contacts to see which blocks are adjacent to each other. The results are quite disappointing, the blocks only get annihilated in few cases. After a lot of debugging, I found the issue, but I still don't know how to solve. My issue is after some time, GetContactList STOPS returning contacts (return NULL) to blocks that were already attached for some time. I spent some time reading the Box2D manual as well as some tutorials and still didn't find any clue of what is happening. Below there's some simplified version of the code that I wrote. for(int a 0 a lt blocksList.size() a ) blocksList a .BuildConnections() And on BuildConnections b2ContactEdge edge body gt GetContactList() while(edge ! NULL) if (long check to see if there's a block nearby) add itself to the list to be anihilated globalList.push back(this) if there's, call BuildConnections again on the adjacent block adjacentBody gt GetUserData() gt BuildConnections edge edge gt next I know that there's another issue related to circular inclusions, but I fairly sure that this problem isn't causing the problem with the collisions. You can download my entire code from this page if you'd like http code.google.com p fellz source list


Box2d pathfinding using raytracing predicted collisions I have a Box2d Cocos2d iOS game with enemies that attempt to follow the player (to attack). I'm working on improving the pathfinding logic so that the enemies won't crash into objects in the world. Using raytracing, I know when there's an obstacle between an enemy and the player. I know when the enemy can't see the player. I'm attempting to find a good way for the enemy to navigate around the obstacle, no matter what direction it's facing. Right now, I start with the angle between the enemy and the obstacle. I gradually increment the angle, looking for any on obstructed path that will allow the enemy to travel further than the obstacle's distance. This seems to work well so far, but it doesn't take into account the size of the enemy. For example, if I have a 32px squared enemy, the raytrace may find a clear path that would involve the edges of the ship hitting an obstacle. Is there a way I can run a raytrace, predict collisions for something with a known width? Or is there a better way for my enemies to navigate around an obstacle.


Libgdx explain steps for beginner to create and use image as a box2d body I am basically from corona background and new to LibGdx , familiar with stage and actor from scene2D. Now wants to use physics body from box2d in the game besides using actor from scene2D. But I need to use images in the game as body... not shapes.. anyone please explain me the steps to use images as a body. Thanks..


Is it easy to switch from Chipmunk to Box2D? Currently I'm doing some prototyping with physics in Python and I later plan to port the code over to C . Box2D has some features that I really like so I'd rather use that library instead. The problem is that the Python port of Box2D is pretty tedious to install and I'm lazy, D while the Chipmunk port is very easy to install. Is it hard for me to switch libraries later on when I port the code to C ? (Will I have to do big architectural changes?)


How to use the testbed with box2dflash? I have made games with box2dflash, but how much ever i have wanted to try out the test bed, the resources on the net don't help me. I have a folder called Testbed and various Test???.as files inside it. It would be a great help if somebody could just jot down how the testing of a box2dflash game is done. Thank you


Box2D body jitters when colliding with static body I am developing a game where a body is moved within the scene using touch. The scene has a boundary wall made up of static rectangular bodies. When I move the object along the boundaries, on collision, it jitters. This is because the boundary wall pushes the body outwards while the touch pushes it against the wall. I am using linear velocity to move the body using touch. I tried to avoid this by setting the linear velocity of the body to 0 on collision with the boundary wall but it didn't work. I am trying to have a smooth movement along the boundary walls with no jitters. How can I solve this? Following snippet moves the body on touch. Linear velocity vector has direction towards the touch point. The movement is smooth within the play area but not at the boundaries. case TouchEvent.ACTION MOVE strikerBody.setLinearVelocity((pSceneTouchEvent.getX() body.getPosition().x PIXEL TO METER RATIO DEFAULT),(pSceneTouchEvent.getY() body.getPosition().y PIXEL TO METER RATIO DEFAULT)) These are the bounadry walls final Rectangle groundLeft new Rectangle(camera.getWidth() 2 camera.getWidth() 4, 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle groundRight new Rectangle(camera.getWidth() 2 camera.getWidth() 4, 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle roofLeft new Rectangle(camera.getWidth() 2 camera.getWidth() 4, camera.getHeight() 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle roofRight new Rectangle(camera.getWidth() 2 camera.getWidth() 4, camera.getHeight() 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle leftTop new Rectangle(1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16 , 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final Rectangle leftBottom new Rectangle(1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16, 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final Rectangle rightTop new Rectangle(camera.getWidth() 1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16, 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final Rectangle rightBottom new Rectangle(camera.getWidth() 1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16, 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final FixtureDef wallFixtureDef PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f) PhysicsFactory.createBoxBody(this.mPhysicsWorld, groundLeft, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, groundRight, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, roofLeft, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, roofRight, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, leftTop, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, leftBottom, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, rightTop, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, rightBottom, BodyType.StaticBody, wallFixtureDef).setUserData("wall") this.attachChild(groundLeft) this.attachChild(groundRight) this.attachChild(roofLeft) this.attachChild(roofRight) this.attachChild(leftTop) this.attachChild(leftBottom) this.attachChild(rightTop) this.attachChild(rightBottom)


Get Vertices of a Shape Body in Box2D Is there a way to do it? I can get only polygon shape's vertices, but i want circle, box, etc too. How to do it?


Getting Bodies to go "Super Fast" in Box2D I am making a breakout game in Android using the LibGDX version of Box2D. I have a ball that I am applying a force to with the following code... getBody().applyForceToCenter( 10000000000.0f, 10000000000.0f) This makes the ball move properly, but it never seems to gain a lot of speed (and I want to make it go super fast). I tried adding an accelerate method where I applied the force 40 times, but again it doesn't seem to move that fast. What is a good way to make a Body go "Super fast" in Box2D? If there is acceleration I would like it to be as short as possible. I tried adding the following.... World.setVelocityThreshold(1000000.0f) But now the ball doesn't seem to "bounce" off walls, do I need to raise my restitution or something?


How do I duplicate a Box2d simulation, mid simulation? I want to serialize the state mid game, send it over the network to an identical computer (same CPU, same OS, same binary), load it there, and have the two games run in tandem doing the exact same simulation, without one of them drifting off and going haywire. In short I want pop in, pop out networking support on my HIGHLY physics intensive game, where sending object coordinates every few seconds is impossible, due to having thousands of objects, and many clients. I tried this with Box2D, and saving an object's location velocity etc wasn't enough... there's internal state that's not accessible through any public methods. My current workaround is to force EVERY client to save its entire worldstate and reload it from scratch, whenever a new player connects... but this is obviously bad practice, because it hangs the game for everyone whenever someone new connects. However, it works, with zero desynchronization. So, anyone know of any other techniques that can help me? Or should I just kiss my project goodbye?


How do I copy box2d data from one body to another? I want to copy all Box2D related data (position, velocity, rotation, impulse, ...) from one body to another. This is what I've got working (with box2djsweb) var t body.GetTransform() other body.SetTransform(t) var vel body.GetLinearVelocity() other body.SetLinearVelocity(vel) I think that covers most things, but judging by the behaviour, I've missed something. It's as if it's a frame or tick behind. Also, this isn't placing the other body in the exact location as the the original body. Is there a better way to do this?


Ring and Pole Box2d How I can make a b2Body in box2d so that it could form a ring which does not collide from the center just like a ring. like when we flick the object and there's another body (like pole), the pole can go inside from the ring. like this


Change the shape of body dynamically I have a problem where i have a ballon which i need to continuously inflate and defalte in update method, I have tried to used setScaleCenter but it is not giving desired result. Below is a code i am trying to make work scale (float) ((dist lastDist) lastDist) Log.d("pinch","scale is " scale) Log.d("pinch","change in scale is " (float) ((lastDist dist) lastDist)) player.setScaleCenter(scale, scale) player.setScale(scale)


Making a physics body so that another body passes through Basically I "think" I want a static body that does not have any density so another body can "pass through it" without getting slowed down. I tried this and it doesn't seem to work. What would be the proper way to do this? Any version (C,C , Java) would be fine for an answer.


Box2D Farseer Collision Detection I am looking for literature or a simple explanation on how the Farseer (and for that reason, the Box2D) collision detection system works specifically the logic that comes after the broadphase culling What data structure does it use? How does it use that data structure to determine if a collision has occurred? How does it calculate the response normals? NB I am not asking how to use it, I merely want to know how it works as a matter of personal enlightenment.


Box2d What is the best approach to build static Box2d smooth curve line i want to know what is the best approach to simulate smooth curved line as static body it will be like path for car to drive . something like this http www.freeriderhd.com how does its box2d static body are constructed ? Thanks


In Box2D, what exactly does a fixture represent? In Box2dWeb, when we create a body we attach a fixture to the body object. We make the shape, friction, restitution and so on by tinkering with the fixture object. So from this can we conclude that the fixture is what we really need to tinker with to get the body we want, and the body object we create just an abstract entity? Abstract in the sense that by itself, it is invisible in the canvas after we draw and animate the canvas? The body is just the abstract, formless object that becomes physical once we attach the fixture. Is this right to conclude?


Making the player walk on walls in box2d I'm making a game in stencil where players walk form left to right along randomly generated walls. I cant use waypoints, since the walls' shapes and positions are unpredictable. Here's a descriptive sketch The red line is the player's path. The red circles are what I thought might make good waypoints until I scrapped the idea.


Unable to find good parameters for behavior of a puck in Farseer EDIT I have tried all kinds of variations now. The last one was to adjust the linear velocity in each step newVel oldVel 0.9f all of this including your proposals kind of work, however in the end if the velocity is little enough, the puck sticks to the wall and slides either vertically or horizontally. I can't get rid of this behavior. I want it to bounce, no matter how slow it is. Retitution is 1 for all objects, Friction is 0 for all. There is no gravity. What am I possibly doing wrong? In my battle to learn and understand Farseer I'm trying to setup a simple Air Hockey like table with a puck on it. The table's border body is made up from Vertices aBorders new Vertices( 4 ) aBorders.Add( new Vector2( fHalfWidth, fHalfHeight ) ) aBorders.Add( new Vector2( fHalfWidth, fHalfHeight ) ) aBorders.Add( new Vector2( fHalfWidth, fHalfHeight ) ) aBorders.Add( new Vector2( fHalfWidth, fHalfHeight ) ) FixtureFactory.AttachLoopShape( aBorders, this ) this.CollisionCategories Category.All this.CollidesWith Category.All this.Position Vector2.Zero this.Restitution 1f this.Friction 0f The puck body is defined with FixtureFactory.AttachCircle( DIAMETER PHYSIC UNITS 2f, 0.5f, this ) this.Restitution 0.1f this.Friction 0.5f this.BodyType FarseerPhysics.Dynamics.BodyType.Dynamic this.LinearDamping 0.5f this.Mass 0.2f I'm applying a linear force to the puck this.oPuck.ApplyLinearImpulse( new Vector2( 1f, 1f ) ) The problem is that the puck and the walls appear to be sticky. This means that the puck's velocity drops to zero to quickly below a certain velocity. The puck gets reflected by the walls a couple of times and then just sticks to the left wall and continues sliding downwards the left wall. This looks very unrealistic. What I'm really looking for is that a puck wall collision does slow down the puck only a tiny little bit. After tweaking all values left and right I was wondering if I'm doing something wrong. Maybe some expert can comment on the parameters?


Box2d Is there a way to have collisions but ignore the accompanying forces? To begin, I know that you can use filtering or isSensor to remove physical collisions. However, I would like to retain the ability to, say for example, stop when trying to move past another player. Essentially, I don't want one player to be able to push another dynamic body with the force that normally accompanies a collision. I've tried static and kinematic bodies, but both obviously have their own problems with trying to have collisions. An example might be a topdown game such as League of Legends of Starcraft, where units can impede on eachother's movements, but don't apply any force upon collision.


how can i move static box2d object how can i move static box2d sprites. i have tried this tutorial from . http www.raywenderlich.com 475 how to create a simple breakout game with box2d and cocos2d tutorial part 12. I managed to add another "paddle" object with box2d body, but i can seam to be able to make the code to move the second "paddle" body. Can anyone direct me how to do it? Is there a way to move a "b2 staticBody" box 2d object? i have tried, but i can only move it when i use "b2 dynamicBody" if i used "b2 staticBody" i can move it at all.


Stopping on a slope in Box2d I am creating a simple platformer using Box2d. I've implemented a variant of the technique described here. To make the player character move more 'platformer like' I want him to stop on (shallow) slopes. However, the engine I am using does not support angle joints, so I have trouble restricting the movement of the wheel. I've tried some different alternatives that not worked Setting the horizontal velocity to 0 every game loop doesn't seem to work, because between calls the wheel catches up speed once again. Is there another way to fix this?


How to apply impulse to a body to make it fly away? I'm playing around with jbox2d and can't really make a body "fly away" as if from an explosion. From what I have found on the net, making the body fly away from the world center (0,0), should have been something like that b.applyLinearImpulse( new Vec2(0,0) , b.getPosition() ) But really it just doesn't do anything, any idea why? Also how do I change the strength of the impulse, like if it want to make it fly skyhigh or just move a bit?


Errors happen when using World.destroyBody( Body body ) on Android application using libgdx, when I use World.destroyBody( Body body ) method, once in a while the application suddenly shuts down. Is there some setting I need to do with body collision or Box2DDebugRenderer before I destroy bodies? Below is the source I use for destroying bodies. private void deleteUnusedObject( ) for( Iterator lt Body gt iter mWorld.getBodies() iter.hasNext() ) Body body iter.next( ) if( body.getUserData( ) ! null ) Box2DUserData data (Box2DUserData) body.getUserData( ) if( ! data.getActFlag() ) if( body ! null ) mWorld.destroyBody( body ) Thanks


What is inertia in a physics engine? Inertia seems to be useful in a physics engine, so useful that even in Box2DLite, a demo of Box2D it hasn't been omitted. See this Body class from Box2DLite struct Body Body() void Set(const Vec2 amp w, float m) void AddForce(const Vec2 amp f) force f Vec2 position float rotation Vec2 velocity float angularVelocity Vec2 force float torque Vec2 width float friction float mass, invMass float I, invI inertia and reverse inertia In the implementation of the class, inertia is set as the mass multipled by something I mass (width.x width.x width.y width.y) 12.0f invI 1.0f I What does this formula means ? I understood from wikipedia that Inertia is how much something doesn't want to move but there's not much formulas in this article. Why is it useful in a physics engine ? How is it used in the context of a collision ? Is it compared to other bodies ?


Reduce bounciness of dynamic bodies in Box2D In my 2D platformer game my player character is modeled using a Box2D dynamic body. One thing I thought feels off though is that even though the restitution of the fixture applied is zero, the player will bounce off static geometry when falling at an angle, kind of like a plastic box would perhaps, but certainly not like a body would. There isn't really much that Box2D allows me to tweak though except for density and restitution? I noticed that playing with the density has basically no effect on how the player moves which I thought was odd too. Are there any realistic value ranges you would recommend? It's all a bit trial and error right now for me.


How to move a b2Body explosively to a new Location I am building an Game based on Box2d with the following basic structure The Box2d World itself does not have any Gravity and is filled with some bodies (sheres and simple polygons) of more or less the same size. The user can select on of them and if he clicks on the free space, the selected body should be moved onto the "point of click". The movement should be explosive, what the use of b2Body.ApplyImpulse suggests, but also stop quickly when the point is reached. This leads me to two problems Which method should i use ApplyImpulse or ApplyForce? How could I calculate the right vector of the impulse, if you would use this method? How could I correct the body's way if it collides with another? Greetings Philipp


Scaling bodies in box2d and libgdx Is there a way to scale the bodies made from vertexes (like a guitar), i was trying to multiply each vertex point by the scale value but c mark an assertion failed, is there a mehtod to do this? I have done it, but i want to make a mirror body, but i cant do it just multplying it by 1 or 1 it doesnt run


cocos2d Merging box2d bodies i'm using cocos2d to build an iphone game. my game currently has two sprites one for the main character and another for an item i should carry once he gets on him. the main character and the item are both box2d bodies. i can detect the collision between the two. what is want is to make the item body stick to the main character body when they meet, that way any movement of the main character would also affect the item. any suggestions on how to implement this? thanks!


Relative movement in Box2D (keep object from falling off planet) I'm creating a game with planets orbiting around a sun, like this The brown square is the earth, rotating around its center and around the sun. The yellow square is the sun, which doesn't move. Now imagine a player standing on the planet, the planet moves at a velocity of 20 m s. How do I prevent the player from falling off? I have to give the perception to the player that the planet isn't moving. I got the gravity on earth working, but I don't know how I can keep the player on the planet! I have thought about two solutions until now Just apply the angular velocity and linear velocity of the planet on the player (if it's in a specified radius), I think this method will cause jittery movement glitches. Create a separate Box2D world for the planet and render this Box2D world with the rotation translation of the planet. This method is complex though since it would add the problem of moving bodies between different worlds if the player would leave the planet. This image explains it I think there is another (better) way to fix this problem, but I haven't found a solution yet.


Explain the difference between extrapolation and interpolation http www.unagames.com blog daniele 2010 06 fixed time step implementation box2d here there are two algorithms of smoothing in case of fixed time step physics simulation. I don't understand the formula of interpolation state currentState alpha previousState (1 alpha) And also I don't understand the comparison figure. Please explaing what is the meaning of multiplying current state with alpha and summing with previous state with 1 alpha.


Starter love2d physics program not working I am starting out with my first love2d (using L VE 0.8) physics program. I am just creating some ground floor, a car body and attaching two wheels with revolute joints and setting the motors a go. However, the car stands still, whereas I expect it to move. Can someone glance over the code below and see what I am doing wrong? UPDATE See below! function love.load() Set up world love.physics.setMeter(50) world love.physics.newWorld(0, 9.81 50, true) Window dimensions windim height love.graphics.getHeight(), width love.graphics.getWidth() objects Ground Floor objects.ground objects.ground.body love.physics.newBody(world, 300, windim.height) objects.ground.shape love.physics.newRectangleShape(2000,20) objects.ground.fixture love.physics.newFixture(objects.ground.body, objects.ground.shape) objects.ground.fixture setFriction(3) Body of the car a rectangle objects.carbody objects.carbody.body love.physics.newBody(world, 300, 500, "dynamic") objects.carbody.shape love.physics.newRectangleShape(100,40) objects.carbody.fixture love.physics.newFixture(objects.carbody.body, objects.carbody.shape) objects.carbody.fixture setFriction(3) objects.carbody.fixture setDensity(3) objects.carbody.fixture setRestitution(0) First wheel objects.wheel objects.wheel.body love.physics.newBody(world, 330, 520, "dynamic") objects.wheel.shape love.physics.newCircleShape(20) objects.wheel.fixture love.physics.newFixture(objects.wheel.body, objects.wheel.shape) objects.wheel.fixture setFriction(3) objects.wheel.fixture setDensity(3) objects.wheel.fixture setRestitution(0.6) Second wheel objects.wheel2 objects.wheel2.body love.physics.newBody(world, 270, 520, "dynamic") objects.wheel2.shape love.physics.newCircleShape(20) objects.wheel2.fixture love.physics.newFixture(objects.wheel2.body, objects.wheel2.shape) objects.wheel2.fixture setFriction(3) objects.wheel2.fixture setDensity(3) objects.wheel2.fixture setRestitution(0.6) Create joint between car body and first wheel objects.carbody.wheeljoint1 love.physics.newRevoluteJoint(objects.carbody.body, objects.wheel.body, 330, 520) objects.carbody.wheeljoint1 enableMotor() objects.carbody.wheeljoint1 setMaxMotorTorque(10000) Following example from http www.emanueleferonato.com 2011 08 22 step by step creation of a box2d cartruck with motors and shocks Create joint between car body and second wheel objects.carbody.wheeljoint2 love.physics.newRevoluteJoint(objects.carbody.body, objects.wheel2.body, 270, 520) objects.carbody.wheeljoint2 enableMotor() objects.carbody.wheeljoint2 setMaxMotorTorque(10000) end function love.update(dt) Set contstant speed for the wheels objects.carbody.wheeljoint1 setMotorSpeed(20) objects.carbody.wheeljoint2 setMotorSpeed(20) world update(dt) end function love.draw() love.graphics.print(objects.carbody.wheeljoint1 getMotorSpeed(), 10, 10) Render ground love.graphics.setColor(72, 160, 14) love.graphics.polygon("fill", objects.ground.body getWorldPoints(objects.ground.shape getPoints())) Render car body love.graphics.setColor(72, 160, 200) love.graphics.polygon("fill", objects.carbody.body getWorldPoints(objects.carbody.shape getPoints())) Render wheels love.graphics.setColor(193, 47, 14) love.graphics.circle("line", objects.wheel.body getX(), objects.wheel.body getY(), objects.wheel.shape getRadius()) love.graphics.circle("line", objects.wheel2.body getX(), objects.wheel2.body getY(), objects.wheel2.shape getRadius()) end UPDATE I added a line to print the angle of one of the wheels (see below). When this line is present, suddenly the car flips over from the wheels spinning when it hits the ground. This leads me to believe that something did not get initialized properly first time around. This is the line added function love.draw() love.graphics.print(objects.wheel.body getAngle(), 10, 10) Line added


Make player to always move along the terrain I'm working on a 2D platformer side scroller game. I am giving high impulse to player, the player starts moving and if it hits a slope on terrain, it gets a vertical movement and starts to fly over (Box2D physics). What I need is that the player should always be on the terrain and move along the ground. I would like to know if it's possible using Box2D engine.


Cocos2D Box2D body that is movable by one type of object but not another I'm in the process of creating a simple platform game using Cocos2D 2.0 and Box2D. I'm trying to create a kind of crate object that cannot be moved by the player, but that can be moved by an elephant object. When the player runs up to the crate, it should stop him dead in his tracks (as if he is running into a static Box2D body). If the elephant runs into it it should get knocked out of the way (as if the elephant was running into a dynamic Box2D body of much smaller mass density). I can't use collision bitmask because of course I want collision to occur in both cases, I just want that collision to result in different things depending on which type of object is hitting the crate. Anyone have a hint as to how to make this work? Thanks in advance!


Box2D body jitters when colliding with static body I am developing a game where a body is moved within the scene using touch. The scene has a boundary wall made up of static rectangular bodies. When I move the object along the boundaries, on collision, it jitters. This is because the boundary wall pushes the body outwards while the touch pushes it against the wall. I am using linear velocity to move the body using touch. I tried to avoid this by setting the linear velocity of the body to 0 on collision with the boundary wall but it didn't work. I am trying to have a smooth movement along the boundary walls with no jitters. How can I solve this? Following snippet moves the body on touch. Linear velocity vector has direction towards the touch point. The movement is smooth within the play area but not at the boundaries. case TouchEvent.ACTION MOVE strikerBody.setLinearVelocity((pSceneTouchEvent.getX() body.getPosition().x PIXEL TO METER RATIO DEFAULT),(pSceneTouchEvent.getY() body.getPosition().y PIXEL TO METER RATIO DEFAULT)) These are the bounadry walls final Rectangle groundLeft new Rectangle(camera.getWidth() 2 camera.getWidth() 4, 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle groundRight new Rectangle(camera.getWidth() 2 camera.getWidth() 4, 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle roofLeft new Rectangle(camera.getWidth() 2 camera.getWidth() 4, camera.getHeight() 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle roofRight new Rectangle(camera.getWidth() 2 camera.getWidth() 4, camera.getHeight() 1, camera.getWidth() 2, 20, this.resourcesManager.vbom) final Rectangle leftTop new Rectangle(1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16 , 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final Rectangle leftBottom new Rectangle(1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16, 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final Rectangle rightTop new Rectangle(camera.getWidth() 1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16, 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final Rectangle rightBottom new Rectangle(camera.getWidth() 1, camera.getHeight() 2 camera.getHeight() 4 camera.getHeight() 12 camera.getHeight() 16, 20, camera.getHeight() 2 camera.getHeight() 12, this.resourcesManager.vbom) final FixtureDef wallFixtureDef PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f) PhysicsFactory.createBoxBody(this.mPhysicsWorld, groundLeft, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, groundRight, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, roofLeft, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, roofRight, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, leftTop, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, leftBottom, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, rightTop, BodyType.StaticBody, wallFixtureDef).setUserData("wall") PhysicsFactory.createBoxBody(this.mPhysicsWorld, rightBottom, BodyType.StaticBody, wallFixtureDef).setUserData("wall") this.attachChild(groundLeft) this.attachChild(groundRight) this.attachChild(roofLeft) this.attachChild(roofRight) this.attachChild(leftTop) this.attachChild(leftBottom) this.attachChild(rightTop) this.attachChild(rightBottom)


Speed of bodies in Box2D and libgdx I want to move my bodies at higher speeds, but they have a top speed. I have an Ortoghraphic camera defined at 800x480. My world doesnt have gravity. I apply an impulse of 1000,and a force of 1000 too. But the speed always is at the same value, it doesnt have more. How do i add more speed to my body (its a dynamic body).


Change the shape of body dynamically I have a problem where i have a ballon which i need to continuously inflate and defalte in update method, I have tried to used setScaleCenter but it is not giving desired result. Below is a code i am trying to make work scale (float) ((dist lastDist) lastDist) Log.d("pinch","scale is " scale) Log.d("pinch","change in scale is " (float) ((lastDist dist) lastDist)) player.setScaleCenter(scale, scale) player.setScale(scale)


What to use as a Box2D renderer in a release version? I'm creating a game with libgdx. For testing physics I use a Box2DDebugRenderer, which is not fast. When I want to release my full game, what should I use as a renderer?


Why might a body suddenly stop while moving on continue platform? I have a 32x32 sprite and I make some to be platform like this for (int i 0 i lt 15 i ) attachChild(new Ground(32 i, 200, regPlatform, vertexBufferObjectManager, physicsWorld)) And I have another sprite (32x32 also) moving over those platforms (A player object) attachChild(new Player(10, 10, regPlayer, vertexBufferObjectManager, physicsWorld)) And the physicsWorld connects the player like this (Where move 1 when user click right button, and move 2 when user click left button) physicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, false) if (move 1) body.setLinearVelocity(new Vector2(8, body.getLinearVelocity().y)) else if (move 2) body.setLinearVelocity(new Vector2( 8, body.getLinearVelocity().y)) The Player moves smoothly form left to right and reverse. But sometimes, it is blocked. If the player move back a bit, and back again where it is blocked, it isn't blocked any more at the same place. Anyone has any idea to fix this? Maybe it is a bug of andengine and box2d and I need some trick here? Please help me. (The two sprites above are just normal png with 32x32px) Player image Platform image


Include Box2D libraries to a cocos2d project (iOS) I have a problem including box2D to my cocos2d project. I've tried different ways to do it with no success. This is what I've done I downloaded Box2D (Box2D v2.2.1) to my project directory. Dragged the Box2D directory (which includes Box2D.h, Collision, Common, Dynamics, Rope) to my Xcode project (from Finder to Xcode) Then I added include "Box2D.h" to my .h file and got many errors... Here is where I started my research P I went to Project Settings and edited the attribute Header Search Paths (contained in the Search Paths section) specifying the path of Box2D. At this point, I builded the project and I got less errors. After that, I renamed my .m file to .mm (I think this is because Box2D is written in C and with this, the compiler can treat it as it is). Still got errors. Then I tried changing the attribute Always Search User Paths (contained in Project Settings Search Paths) from YES to NO. Still got errors. As my last option I tried changing the attribute Compile Sources As (contained in Project Settings LLVM GCC 4.2 Language) from According to File Type to Objective C . By now I'm frustrated xD. I have 203 errors and most of them are in the .h files contained in the Box2d engine. b2Timer.h Expected ' ', ',', ' ', 'asm' or 'attribute' before 'b2Timer' b2Distance.h Expected specifier qualifier list before 'b2DistanceProxy' b2Math.h Cfloat No such file or directory And so on... Thanks!!!


Box2D recommended step, velocity and position iterations Here in this article there is a nice explanation that velocity iterations and position iterations settings affect the way bodies will react when they collide, and step affects on speed and how gravity acts. So the precision is hidden behind position and velocity iterations, whereas you need to have the world step to advance the time in physics world. I also know that step should be constant to be able to have consistent and debug able game physics. Hence I do this (where dt is FPS delta time) if (m world.GetBodyCount() gt 0) static const double step 1.0 70.0 static double accumulator 0.0 max frame time to avoid spiral of death if ( dt gt 0.25 ) dt 0.25 accumulator dt while (accumulator gt step) m world.Step(step, VELOCITY ITERATIONS, POSITION ITERATIONS) accumulator step So I guess the step should not be less then FPS minimum value to avoid discrete simulation (cutting effects). Usually FPS is 1 60.0 hence I have chosen 1 70 as a step to have the best performance. And as Velocity and Position iterations I use 6 and 2 respectively which turned to be enough for collisions till today. Is my logic correct or I miss something? Is there a way to optimize more? What are the recommended values for this parameters for mobile games (considering that the game should work on week devices too). Should I use non constant velocity iterations and position iterations reducing them when FPS drops?


Stopping on a slope in Box2d I am creating a simple platformer using Box2d. I've implemented a variant of the technique described here. To make the player character move more 'platformer like' I want him to stop on (shallow) slopes. However, the engine I am using does not support angle joints, so I have trouble restricting the movement of the wheel. I've tried some different alternatives that not worked Setting the horizontal velocity to 0 every game loop doesn't seem to work, because between calls the wheel catches up speed once again. Is there another way to fix this?


Box2d contant speed before and after collision I want to make my body fly at constant speed, how to make it fly at constant speed before and after collision? I set restitution of my body to 1.0 but after some direct and powerful collisions my objects begins to slow, I want it to fly same speed as before. I heard this can be done by setting liner damping of the object, I think it can prevent only from fast flying objects not slow. Thanks in advance. Edit I can simply modify velocity of the object every frame, is it a solution? var velocity b2Vec2 b.GetLinearVelocity() var speed Number velocity.Length() var ratio Number circleSpeed speed velocity.Multiply(ratio) b.SetLinearVelocity(velocity)


What is the Box2D coordinates system? I know that for Box2d I need to translate pixels to meters which is easy peasy. However my problem is what is the orientation of Box2D coordinates system? Is this the same as screen one (right x, bottom y) or it is like cartesian (right x, bottom y) ? Also, does Box2D coordination system use negative values? Thank you.


Is it bad practice to set the velocity of an object every loop? Say I have a simple game with a gameLoop function that gets called every 50 milliseconds or something similar, and I have a box2d object. Is it bad practice too CPU intensive to use SetLinearVelocity on the object every time the gameLoop is called?


Libgdx body passing through block then fall on it I'm using libgdx and its physic engine Box2d. My question is how could I make my box2d body go through a block , ignore the first collison than make the block active so the ball can fall onto it. A good example is doodle jump.


Speed seems random with constant impulse I'm shooting an object from the top vertex of a triangle using Box2dWeb. The issue I'm having is that the projectile speed seems to be fairly random, even with applyimpulse set to a constant. The gravity is set to zero. I thought it could be the physics step, changing these settings hasn't made a difference. The projectile will shoot out at very very fast speeds, then it will shoot out at its defined speed. bodyman 0 .GetBody().ApplyForce( bodyman 0 .GetBody().GetWorldVector(new b2Vec2(0, 50)), bodyman 0 .GetBody().GetWorldCenter())


Worth using Box2d for collision but not physics? I am currently doing some work in cocos2d x and am thinking about using their box2d implementation for things like collision detection (but not necessarily response), range detection, and other things like that, which are not strictly physics based. Is it worth doing this? or would I be better off just writing a simple system that does checks based on location size of my objects?


How do the Box2d and Bullet physics simulations work internally? I've seen box2d and bullet ported into JavaScript, but neither of them attracted me, except for the source code. It all seemed quite simple, once I looked inside. What are they doing within each of those libraries to get nice physics simulation? I can not find any explanation.


In Box2D, how do I create an infinitely oscillating spring? How do I create an ideal spring that can oscillate indefinitely using Box2D? A b2DistanceJoint works almost perfectly, but it eventually slows to a stop, even with damping set to 0. I think it is because b2DistanceJoint is not meant for creating springs, but for preserving the distance between two bodies by correction the violated distance with a spring like behaviour. Hence, it should have a damping to eventually bring back the bodies to initial state and stop at some point.


Can i add friction in air? I have issue regarding speed in air. When i jump and move simultaneously that time speed of player increase.For jump i am using impuls and for movement i am using force.I want to slow speed when player is in air. Thanks in advance Following is my update method ih HUDLayer (void)update (ccTime)dt (b2Body )ballBody (CCSprite )player1 (b2World )world if (moveRight.active YES) ballBody gt SetActive(true) b2Vec2 locationworld b2Vec2(maxSpeed,0) double mass ballBody gt GetMass() ballBody gt ApplyForce(mass locationworld, ballBody gt GetWorldCenter()) ballBody gt SetLinearDamping(1.2f) else if(moveLeft.active YES) ballBody gt SetActive(true) b2Vec2 locationworld b2Vec2( 10,0) double mass ballBody gt GetMass() ballBody gt ApplyForce(mass locationworld, ballBody gt GetWorldCenter()) ballBody gt SetLinearDamping(1.2f) Following is jump (void)jump (b2Body )ballBody (ccTime)dt (BOOL)touch if (touch) if (jumpSprte.active YES) ballBody gt SetActive(true) b2Vec2 locationWorld locationWorld b2Vec2(0.0f,98.0f) locationWorld b2Vec2(0,32) double mass ballBody gt GetMass() ballBody gt ApplyLinearImpulse(locationWorld, ballBody gt GetWorldCenter()) ballBody gt ApplyForce(mass locationWorld, ballBody gt GetWorldCenter()) ballBody gt SetLinearDamping(1.2f) So where i apply logic??


Rotate Box Sprite With Circle Body I want to rotate my rectangular sprite with circle body. The problem is the body doest not attached to the centre of the sprite. This was the default behaviour of the body and sprite. But I want that circle body attached in the bottom of the rectangle and when rotation happen at that time rectangular sprite always attached with the body at the bottom and during simulation it change its angle and position according to this only. I try to write question in words if I don't able to understand you then know me then I post a picture of my problem here. Although I know that cocos2d has setAnchorPoint method available so similar task become easily but what about my engine that right now I was using AndEngine. So be relevant to this game platform. Also thanks in advance for efforts you take.


Set Position of multiple bodies I have a character composed of five bodies which are tied together by a lot of joints. On of them is the overall chassis, to which all forces and impulses are applied to move the whole Character. All in all that works very fine, except one thing I need to set the Position of the Character so that it get Beamed from one place to the other in one single frame. Unfortunately I cannot get this to work. I tried the following code, without any success playerbodies.forEach(function (bd) bd.SetLinearVelocity(new b2.Vec2()) var t bd.GetTransform() t.p.x 10 bd.SetTransform(t, bd.GetAngle()) ) How can I make that happen?


Programmatically set color of Box2D body's sprite or image In my basic Cocos2D Box2D iPhone app I have a bunch of circular Box2D bodies. I'd like to change the color of the circles programatically. What's the easiest way to do this? So far I'm just assigning a CCSprite to the b2body userData. So perhaps I can change the colors in my sprite sheet programmatically? Seems like there's an easier way. I'm just not sure what it is. Cheers!


Box2D strange collisions (jitter) on sharp edges I'm currently developing 2D side scroll game with Libgdx Box2D. And I'm facing some problems with ChainShape (the ground) and PolygonShape (the cart body) collisions. Please look at this video http www.youtube.com watch?v gljgMn8lYfs As you see the PolygonShape jitters(?) when collides with ChainShape. BUT it only happens on sharp edges! What I've tried Increase decrease velocityIterations positionIterations. Didin't help. Currently they are set to 10 8 (as shown in video). Turn off CCD. Didin't help. Currently is turned on. Set velocityThreshold to zero. Didin't help. Currently is default 1f. Set restitution friction values to zero. Didin't help. Any suggestions why it's happening and how can I fix avoid it?


How to set a body to a specific position using Andengine I'm developing a game with a single player and multiplayer mode. Lets say I have walls (static bodies), vehicles (dynamic bodies) and bullets (dynamic bodies). It works fine to control my own vehicle using vehicleBody.setLinearVelocity(velocityX, velocityY) . The vehicle can collide with walls and bullets as expected. Now I like to move the enemy vehicles in multiplayer mode. When I use the same method to move the body by its velocity values (in multiplayer mode), the vehicles get out of sync really quickly, means they don't have the same position on all devices because some data packages get lost. What I'm currently doing is the following On device 1 1) I move the body using setLinearVelocity 2) Then I get the X and Y position of the body and send a data package to the other device On device 2 3) I receive the data package and set the position of the body. I tried different ways, hopefully you can tell me the best way or alternatives I did not try yet using vehicleBody.setTransform(...) activity.runOnUpdateThread(new Runnable() Override public void run() vehicleBody.setTransform(new Vector2(newPosX, newPosY), angle) ) I also tried using MouseJoint (based on that tutorial), but somehow the body was bouncing randomly to the next position. Sometimes it was working great, but when I restarted the game the vehicle of the enemy started bouncing again. Maybe I failed to setup the parameters. Here is what I used public MouseJoint createMouseJoint(float newPosX, float newPosY) final float PIXEL TO METER RATIO PhysicsConstants.PIXEL TO METER RATIO DEFAULT Vector2 v vehicleBody.getWorldPoint( new Vector2(newPosX PIXEL TO METER RATIO, newPosY PIXEL TO METER RATIO)) MouseJointDef mjd new MouseJointDef() mjd.bodyA groundBody mjd.bodyB vehicleBody mjd.dampingRatio 0.2f mjd.frequencyHz 30 mjd.maxForce (float) (1000.0f vehicleBody.getMass()) mjd.collideConnected true mjd.target.set(v) return (MouseJoint) mScene.mPhysicsWorld.createJoint(mjd) Before I've used bodies I was using simple sprites and it worked perfectly. I sent data packages to the other device(s) and set the position and rotation of the enemy vehicle by using vehicleSprite.setX(newPosX), vehicleSprite.setY(newPosY) and vehicleSprite.setRotation(angle). Compared to that, bodies seem to be very complicated. So how I can I keep positions synced without bouncing? By the way, on some pages I read about using KinematicBody instead of DynamicBody for a vehicle. What is the advantage? My vehicle needs to collide with the environment, so I think DynamicBody is the correct choice, isn't it?


Farseer Friend Foe Collision cannot push foes but friends we are using Farseer in our project and I try to find a setup to achieve the following quite complicated collision behavior Friendly Units can push each other aside. However, the push should be a "soft push", so that multiple units can squeeze through narrow gaps. Enemy Units should not be pushed. Ever. Moving units colliding with enemies should stop dead. Additionally, I have some other type of collider, lets call them "Wall" ). Neither friends nor foes should ever be able to stand inside a wall. Whether two objects are considered "enemies" can change dynamically during the game. The state is always symmetric (If Bob is an enemy of Alan, then Alan is always an enemy of Bob) but we have more than two factions (up to 16). (Basically, its a similar collision behavior like Starcraft, except that friendly units can temporarily squeeze through navmesh gaps.. much like in Age of Empire..) Actually, I got a quite elaborated solution so far. It has some problems, but kind of gets most of my wishlist done.. Well, most of the time. Here is what I did.. Lets first start with the setup without any walls (because that's what is working better ) I have 2 bodies for each unit. One dynamic the other kinematic. the dynamic body has two equal fixtures. One sensor (to soft push friends), the other a normal fixture (this is what I apply forces from outside game code). The kinematic body has one normal fixture. (This body is to dead stop on enemies) I hooked a BeforeCollision callback to the normal fixture of the dynamic sensor. This filters out all collisions except with the kinematic body of enemies. This way, the dynamic body can not push enemies. Another BeforeCollision filter on the kinematic body just excludes collisions with the sensor fixture of our own dynamic body. Now, after every world update, I run through all the dynamic bodies I will copy the new position into the kinematic body. For each touching contact of the sensor with another dynamic body, I will manually calculate a separating force and apply these to both dynamic bodies. Everything clear so far? To summarize Dynamic fixture moved by game code, stops dead colliding with kinematic body of enemies. Sensor register friends and I calculate push forces by hand. Kinematic body is synched every frame to the dynamic body. Now the problem Walls. I need to enforce that no Body ever ends up inside a wall. More precise, the center point of any body must not be inside any Wall shape (the circle can and should overlap with the wall, only the center point is interesting). I tried several ideas to achieve this but running out of steam here. The currently best solution I could come up with The dynamic body gets yet another circle fixture that is extremely small, like 0.001 meter. This one has a CCD on and a collision group that only allows collision with walls (which are in their own category) Walls are all fixtures of a static body. This approach works as long as no "teleporting" of units is involved. Lets say Alan is being teleported on a spot overlapping with Bob. Now, Alan's kinematic body will push Bob's dynamic body and vice versa. Everything is fine. But if Bob was standing right next to a wall, Farseer will still move Bob slightly into the wall, since the resolver need to resolve the unmovable kinematic body of Alan and the unmovable wall. Yet another post update loop through all bodies that scans all units whether they are inside walls and manually resolve their positions is way beyond our performance limits. I briefly thought about some solution involving two separate Farseer worlds, but my head starts to spin trying to figure out which body position need to be copied where and when... I haven't looked into joints yet, but my gut feeling is that they don't really help here. Except with a third body? Do I really need 3 bodies per unit? ( Any ideas?


Explain the difference between extrapolation and interpolation http www.unagames.com blog daniele 2010 06 fixed time step implementation box2d here there are two algorithms of smoothing in case of fixed time step physics simulation. I don't understand the formula of interpolation state currentState alpha previousState (1 alpha) And also I don't understand the comparison figure. Please explaing what is the meaning of multiplying current state with alpha and summing with previous state with 1 alpha.


Rotating an object about a point (2D) using box2d i just started developing using box2d on flixel and i realise the pivot point of the rotation of an object in box2d is set to the center of an object. i had read on forums and i found out that SetAsBox can change the pivot point of the object, however, i cannot seem to get it work to rotate about a point. what i would like to achieve is to rotate an object about a point like earth revolving around the sun. any one can help me with it? really thanks a lot and sorry for the bad english


Making the player walk on walls in box2d I'm making a game in stencil where players walk form left to right along randomly generated walls. I cant use waypoints, since the walls' shapes and positions are unpredictable. Here's a descriptive sketch The red line is the player's path. The red circles are what I thought might make good waypoints until I scrapped the idea.


Box2d How to connect distance joint to the ground? I have a rectangular fixed size world. I want to connect a body inside it to any place(near that body) in the world with a b2DistanceJoint. Do I need to create a large static body with the size of the world that can't collide with anything? Or is there a better method? Will it slow down simulation speed if I have around 300 bodies moving on the surface of this static body?


What scaling system to use in Box2d? I'm worried about this Caution box from the Box2d manual Box2D is tuned for MKS units. Keep the size of moving objects roughly between 0.1 and 10 meters. You'll need to use some scaling system when you render your environment and actors. The Box2D testbed does this by using an OpenGL viewport transform. DO NOT USE PIXELS. I don't want to use OpenGL since I know nothing about it. I'm using SFML to render my game.


Client side physics simulation I am trying to create a very simple client server based physics game, using box2d library. A simple football game. Obviously, the server runs only the box2d world. My question is is it correct to state that the client should run not only the needed rendered simulation but another box2d world as well? I ask this because I know that the client should receive state information of the elements that have a changing state. And this information is received in packets every few ticks. And between every packet received, there's a time gap where I need to run the world like "nobody did nothing", and then correct the world state if somebody did something after I received the next packet. That is why I need to run the box2d world in the client as well, but I feel it's kinda awkward and assymetrical. Is this right? Is box2d prepared for this?


How to make an object in box2d have constant velocity even after collision? I have iOS game where I have a bouncing character. Everything is being handled by box2d. The problem is when the character hits a wall of another character it's velocity changes, but I don't want this. I need the velocity to stay constant even after collisions. I was thinking the only way to do this was to keep setting the velocity after each collision unless there's another way to do this that I'm not aware of?


Dynamic body in Box2D with fixed position I need to fix the dynamic body position so that it would not rotate and would not move even if there are other forces, collisions and so on. Let me first explain why I need this. I have a dynamic body which is the game character. There are non moving objects that the game character should land on and get some energy as long the character is in contact with those bodies. As these bodies are non moving it would be natural to make them Static or Kinematic. But in my case I cannot do that, as far as there is another Kinematic body with which all the game items should be collided and on EndCollision event those items should be removed. But in Box2D static and kinematic bodies don't collided with each other. So I have to make my game item on which the character should land Dynamic but still should be sure that it will not move. How should I do this?


Sizing a Box2D ground object I am developing a platformer game using SDL2 for graphics and Box2D for physics. I am currently designing my levels and would like to know if it is better to make the static part of each level (ie ground) one big (500 units wide) polygon or to break each level up into multiple tiles just a few units wide. The Box2D manual says that I should keep my objects small to avoid bugs in the floating point code but having a single large ground object seems like a resonable way of reducing the number of objects in the simulation. So, can I make my ground object one large 500 unit polygon or should I break it up into many smaller 1 2 unit polygons.


Is it possible to apply a texture inside a GL LINE LOOP? I am creating a game using Box2D and OpenGL ES 1.1. I am taking the b2PolygonShape vertices and converting them into an OpenGL ES 1.1 GL LINE LOOP. The debugging view looks great, but now I want to apply textures to the inside of the line loop. Is this possible? I used line loop instead of triangles because I am not sure how to handle complex polygons using triangles.


Moving player in Box2d without forces How do I move player with keyboard without applying forces? If I do playerBody.setLinearVelocity(new B2Vec2(0, 2)) it moves the player but when I release the key for movement, the ball is continuously moving for few seconds.