Tag Info

New answers tagged

0

This needs to be done when you create the Box2DLight's Light object. You can fix this by setting the setSoftnessLength(float) on the Light object. For example: m_Light = new ConeLight(...); m_Light.setSoftnessLength(1.5f);


1

As per Andy's comment: Nevermind, I fixed it. I just had to take out the p.setCenterX(center.x);p.setCenterY(center.y); out of the render function.


0

I think I got the reason. When I detect jumping time with sensor rectangle, the body at that time sill has velocity towards down. And when I give him impulse towards up direction it decreases its speed towards down (as it turns the impulse was small) and I think that it does not jump. But in case I apply linear velocity, it just starts to move up the the ...


1

I'm assuming that you may be doing setTransform() on PBox to move the player around based on mouse positions. If that's the case, it is bound to happen, since setTransform occurs outside of the physics calculations. Consider adding a Joint to drag the pBox around (with large force).


0

Really, a for loop is usually better for iteration. Taking @noel 's answer: b2AABB aabb; aabb.lowerBound = b2Vec2(FLT_MAX,FLT_MAX); aabb.upperBound = b2Vec2(-FLT_MAX,-FLT_MAX); for (b2Fixture* fixture = body->GetFixtureList(); fixture; fixture = fixture->GetNext()) { aabb.Combine(aabb, fixture->GetAABB()); } The expression fixture, taken as ...


1

Create static bodies A and B, each of them with rectangular fixtures with b2Fixture::setSensor(true). Utilize the b2ContactListener::BeginContact and b2ContactListener::EndContact to determine when a body is entering or leaving areas A or B. When one of these events is detected, modify the gravityScale of the dynamic body accordingly. In pseudocode these ...


0

Friction coefficient is equal to tangent of the maximum angle before the item will slide. You need to set coefficient greater then 1. There is a function in the Settings class - MixFriction. It's used to calculate the friction coefficient between surfaces, by default it's a geometric mean, you can change this too.


1

Your car is slipping for the same reason that a car hanging up-side down, riding the ceiling, with 100% friction would slip. 100% friction roughly means that 100% of the force exerted via the wheels on the terrain is used to counter movement perpendicular along the normal of the terrain. But this force still isn't enough to counter the force of gravity. This ...


1

As I understood your question, you want to get the coordinates of the points of your body relative to the world, in other words, following the transformations applied to the body. I did this function not long ago, I hope this will help you and guide you towards an answer: public Vec2[] getPoints() { Vec2[] v = new Vec2[shape.getVertexCount()]; for ...


3

This is less a problem with Box2dLights, and more a problem with setting up Box2d collision fixtures to match your sprites. The Box2dLight rays are colliding with the CircleShape fixture you attached to the box2d body. CircleShape chain = new CircleShape(); chain.setRadius(10); Instead, this should be a Polygon shape with the same dimensions as your box, ...


0

The method of controlling the anchor points on both of the bodies doesn't seem straightforward at first, but if you think about it in the following manner, it makes sense. Consider two pieces of construction paper such as the rectangle and circle in your example. I can translate and rotate these two pieces anywhere I want on a flat surface. They are allowed ...


0

You're on the right track. The step() method is the right place to put game decision logic. JBox2D's tests directory contains great reference examples. Among them is ApplyForce.java, which is similar to your description. It applies forces to a body based on decision logic—inside step(). Their decisions are based on keyboard inputs, but you could ...


0

Box2D is a physics library for 2d environments. Tweening is the process of gradually interpolating values. Tweening itself is not fundamentally for animation, though it is widely used in animation for smooth transitions.


1

Why calculate the trajectory for the sounds/slow down effects? If you split the act of slowing down the camera and playing effects into sections upon approach to your squishy victim then you can essentially play them on condition of their proximity. This is a great example that comes to mind. The proximity slow down effects employed in Peggle The ball ...



Top 50 recent answers are included