Tag Info

Hot answers tagged

4

Only in exceptional circumstances will players notice or care about the accuracy of your physics simulation. Most games fake calculations like these, which has several advantages; fake calculations are easier to code, computationally less expensive and most importantly, they allow the behaviour of the game to be tweaked in favour of fun rather than realism. ...


3

You've got the moving part right but the rotating adds a significant amount of complexity to the problem. Luckily, you can hack in rotational velocity with a formula mentioned here. It approximates rotational velocity based on the distance from the center of mass to the point of contact, and the positional velocity. Here's an implementation: a = (cp.x * ...


2

I think the amount of entities is the best to test that and to keep things simple just multiply them. Simply add a script to your barrel prefab which will wait 1 second after start and then spawn two more entities of the same object. Add some force to push them away. That way you only have to place one instance on your screen, start your game and wait a ...


2

I would suggest procedurally spawning the object constantly, and adding mesh colliders. Mesh colliders are very cpu intensive, and if you have a script that continuously creates these barrels, it will keep doing so until you kill unity. You can also track your gameplay statistics by clicking on the stats button up the top of your game window.


2

Like Pieter mentioned, you can use 1D kinetic equation for height, which in your case will come to: h = p + vt + 0.5at^2 where a is the acceleration due to gravity. You can then use the quadratic equation to solve for t. Once you have t, you can use the kinetic equations again to calculate how far the ball has travelled width ways. This would tell you ...


2

The skewing is because of how the viewport is setup, try changing it to something like this; @Override public void create() { ... bodyDef.position.set(0, 0); // Let this be at origin for now, it's easier to debug ... camera = new OrthographicCamera(200, 200 * ((float)Gdx.graphics.getHeight()/(float)Gdx.graphics.getWidth()); ...


2

The only new constraint that inertia lays onto path-finding is continuity, which means no sudden breaks in velocity. Start by generating an A* path, but with a big twist. The reason A* by itself is not appropriate is because it violates continuity, so lets make a new one. A* chooses the best path as the shortest path, but with inertia the shortest path is ...


2

Directly editing the position of a box2d body will produce non-physical behaviour, it's present because sometimes you will need to teleport bodies to a far away location, or reset the position of an object without the need to destroy/re-create it, etc... In your case the joints are not handling the position adjustments well. The setPosition function should ...


1

I know this is an old question, but I've just come across this solution and found that making sure restitution is not above 1 is not enough. friction also caused differentiation in the angle of which it bounces off. so setting friction to 0 allowed me to bounce a ball up against a 45* wall and get the expected perpendicular reaction.


1

@Richard Byron explained well and gave a well-made sample code. I think it's better to add additional information about the basic math. I leaved out the wall collision. Sorry for bad hand writing an drawing.


1

There are some optimizations under the hood that prevent the engine from iterating over the total set of colliders every time it checks: layer filtering, active/inactive flags. That said, the fewer items in the list of collidable objects that the collision checker has to go through, the faster the processing will be. It's a simple numbers game. It takes ...


1

Pathfinding algorithms like A* can deal with inertia (or any other dimension you can throw at it) just fine. The key is to treat them as an additional dimension, and create a higher-dimensional search graph to search in. To keep things simple, let's suppose we have only two speeds: slow and fast, and this path: A --(sharp turn)-- B ----------- C ...



Only top voted, non community-wiki answers of a minimum length are eligible