Tag Info

Hot answers tagged

7

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers... This is the solution: void SceneView::centerOn(const QPointF &pos) { if (mScene) { mScene->setX(int(-(pos.x() - width() / 2))); mScene->setY(int(-(pos.y() - ...


2

Emanuele Feronato did a tutorial on this some time ago, you can use it as a base: http://www.emanueleferonato.com/2012/03/05/breaking-objects-with-box2d-the-realistic-way/ To sum it up: Listen to collisions between your breakable body and the bodies that can break it; When collision happens, get the velocity of the body that can break the other and ...


2

I spent a good while looking how to implement Box2D in Android studio, so for anyone else in the same boat, or just looking to implement Box2D - here goes. For implementing Box2D into your java code/framework, Box2D is tuned to work with numbers between 0.1 and 10 (it works in meters), quoting from the Box2D manual: http://box2d.org/manual.pdf Box2D ...


2

It should work if you change these parts in show(): viewport = new ScalingViewport(Scaling.fillY, GAMESCREEN_WIDTH, GAMESCREEN_HEIGHT, camera = new OrthographicCamera()); and add a resize method: @Override public void resize(int width, int height) { int SCREEN_WIDTH = width; int SCREEN_HEIGHT = height; viewport.setWorldSize(GAMESCREEN_WIDTH, ...


2

Your NPC seems to be turning towards the desired angle as it supposed to do, but slowly. Try increasing rotation speed. Judging by the movement pattern, I think that you are passing degrees to a function which takes radians, or vice versa. I think the problem is here: float rotation = physicsComponent->body()->rotation(); QPointF ...


2

I've never tried to get this to work myself, but it seems like you would just need to increase the upward force applied to the jet ski's body as a function of the depth of the jet ski below the "surface" of the water object. The easiest way to get the distance below the surface might be to make a constant variable that describes the height of the water's ...


2

Yep, sounds right. A body abstractly represents a physical entity. A fixture defines its shape, physical properties and which other fixtures it collides with. Technical details in the Box2D manual, Chapter 7: Fixtures. Some reasons they are separate: This separates concerns by allowing the same fixtures to be used for all types of bodies (dynamic, ...


2

When centering the camera using lookAt you need to clamp the y value to be the max of the body's y and the y of the ground plus half the viewport height (possibly adjusting for the height of the ground). Something like this might make sense; float x = body.getWorldCenter().x; float y = Math.max(body.getWorldCenter().y, ground.getWorldCenter().y + ...


1

It looks to me like the original rotation towards the end of the black line was working. It's just a bit slow. What's weird is the movement. It looks like the force in the first one is in the wrong direction (accelerating backwards), and there's a weird wobble, too, like the force may be alternating forward and back between frames. I would start by trying ...


1

I had this class in previous project public class ExtendedCamera extends OrthographicCamera { public Player player; public ExtendedCamera(Player player) { super(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT); this.player = player; } public void followPlayer() { if (player.body.getPosition().x - position.x > ...


1

Sounds like a simple rigidbody setting. Change from interpolate to extrapolate, or vice versa. http://docs.unity3d.com/ScriptReference/Rigidbody2D-interpolation.html


1

This will occur in Unity, if a GameObject is too small. The colliders will end up being either too far or overlapping, as the physics get unstable if the GameObjects are too small. Try making the gameobjects much larger (change the pixel per unit size), and you will see that it will more than likely fix your problem.


1

You could try changing the collision detection to Continuous or Continuous Dynamic. See the Unity Manual: Rigidbody for further info.


1

I was playing around a little and rereading the manual again. It noted that the size of the actual box is 2x the given size. Half-widths. So I continued to play around inside my graphics system and continued to see where the box was colliding and not and ended up with: Negate the (untouched) size from the position. Double the size of the boxes. glm::vec2 ...


1

This is a quite known issue in box2d, the problem is that you are rendering a rectangle per Tile and in the joint of those there is a ghost vertex, you can read extensive explanation here: http://www.iforce2d.net/b2dtut/ghost-vertices As for a solution to that i solved it by creating an object layer in my tiled map and created a Polyline object that defines ...



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