# Tag Info

7

But I need to use images in the game as body... not shapes.. In Box2D, you will need to create shapes anyway, you can't really go without them. A body is composed of fixtures and a fixture is a shape, that's it. Here is the official Box2D manual if you want to read more about those concepts. anyone please explain me the steps to use images as a body As ...

6

Disclaimer: I have not used libgdx or Java before, this answer borrows syntax from the question and official documentation, and the code is untested To make the bodies 'fall' under the influence of gravity in box2d, you must first pass a non-zero gravity vector to the b2World when constructing the world World world = new World(new Vector2(0, -10), true); ...

4

If you are trying to destroy the body in a CollisonEvent, this happens mid-step so you can't do that. Your best bet is to build a list of objects you would like to destroy and have them removed next frame.

4

The easiest way is to use a sensor instead a Body. A sensor generates a collision, but not a response. So you will be notified when they hit, but the hero will not bounce off.

4

What's happening First of all, note that this behavior is not specific to oblique collisions. Below is an example of two balls colliding head on with a wall. All fixtures have m_restitution = 1.0, and m_friction = 0.0. The ball on the left is traveling with v = 0,1 and the ball on the right has v = 0,1.01. I found three similar questions asked on the box2d ...

3

You have to separate your physics simulation (bodies) from the graphical representation of the physics world. Lets assume you have a Box2d body defined like this float radius=3.0f; CircleShape shape=new CircleShape(); shape.setRadius(radius); FixtureDef fd = new FixtureDef(); fd.shape = shape; BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; ...

3

Farseer does ship a physics view, and thankfully it requires very little brain power to implement and use. If you downloaded the "Farseer Physics Engine 3.3.1 Samples XNA" recommended package on their download page, you'd see a lot of examples included. Navigate to (or click these convenient links to the codeplex page :P) SamplesXNA/SamplesXNA/ScreenSystem/...

3

Farseer is open source. http://farseerphysics.codeplex.com/SourceControl/changeset/view/94324#1436535 /// Warning: You cannot reuse fixtures. If you still want to do this, then try to reproduce some of the steps that Fixture.RegisterFixture() private method does.

2

Probably because it is a property and not a normal member variable. You need to change the entire tray.Position variable like this: tray.Position = new Vector2(tray.Position.X + delta.X, tray.Position.Y); Note that properties are a C# language feature. However this is what Farseer considers teleporting an object and this can interfere with the stability ...

2

[Solution] This was a coding error on my part. Pointed out by a good reply above, I was updating the position of the sprite relative to the body and then stepping the physics. Thus never actually setting the sprite to the body's CURRENT position. Thanks!

2

I think I've managed to reproduce your problem - basically your friction is too high/your impulse not enough. Change your impulse from (-5, 0) to something like (-50, 0), and/or lower your friction coefficient. Seems to work... Also, on a side note, I wouldn't recommend instantiating and setting your InputProcessor every frame - do it once in your create() ...

2

I think you can't do it. Phaser groups doesn't have body: http://phaser.io/docs/2.4.4/Phaser.Group But you can use setAll method to set properties to all sprites of a group: http://phaser.io/docs/2.4.4/Phaser.Group.html#setAll Otherwise, if you want more complex objects you could try another type of physics (P2) and make complex bodies with polygons.

1

Instead of a separate variable for each bodypart, as in private Leg rightLeg; private Leg leftLeg; have a list of bodyparts: private List<BodyPart> bodyParts = new List<>(); You can then use getters which return one bodypart (or all bodyparts) which fulfill a specific criteria. For example: // returns the first Head of the creature, or null ...

1

First off, you have redundancy in your state. It is enough to track: angle (scalar.) angular velocity (scalar.) centre of rotation (2d vector.) radius (scalar.) from this you can determine: the body's position (2d vector.) the body's orientation (local frame defined by body-up-vector, a 2d unit vector.) To rotate it with timestep dt, you would do: ...

1

You can use the filter on the FixtureDefinitions to define what type of objects can collide with what. You define a category bit-pattern, this describes what the fixture is. Then you define a set of categories that the fixture collides with. For example; class PhysicsConstants { // Categories public static final int CAT_SHIP = 1; public static ...

1

If you are trying to deduce difference in force and how it effects a single object with a change to its center of gravity, making each component of that object, a single object and then using its force to calculate any strain or pressure would seem to be the way to do it. If you have two weights on a bar, and they rotate around the center, and then you want ...

1

It seems to me that you haven't defined enough of what is happening in your system, to know how it should move. I.e., I think you are missing the forces involved when one of the two component objects rotates itself. In real inertial physics, nothing moves without force being applied, but it sounds like your model for the component rotation may not include ...

1

MouseJoint is not a good idea, it will get out of sync too. It's really meant to be used to make the body move towards the point. setTransform is exactly the same as setting the position and rotation of the Sprite. You just have to be setting the coordinates in meters not pixels. I am not an expert on multiplayer, but the latency will influence it always. ...

1

Farseer comes with a debugging environment. There's two ways of doing what you want to do. The first way is reproducing your situation in the test environment they ship. It will show everything of relevance. This is the technique I used for my game. The other way is to integrate the debugging environment they made into your game, this is slightly more ...

1

I'd go with spheres. When you grow, add new spheres to the existing ones (at different directions) more to the 'base spheres', less to the farther away ones, organized like this : Sphere B is 100 units from sphere A at "vector" 0.7 ; 0.3 ; -0.4 or just use the final vector 70.0 ; 30.0 ; -40 to connect B to A. You can even predefine the link points on ...

1

One is falling from the top and the other one which is static is at the button of the screen and is supposed to be used to catch the object that is falling. Sounds like you should use a kinematic body instead of a static one and adjust its velocity so that it moves towards the targeted location quickly when its far away and none at all when the x position ...

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