Tag Info

Hot answers tagged

5

A physics engine being tied to a particular renderer shows horrible separation of concerns and really shouldn't happen. In fact, it doesn't. Box2D-js can visualise the simulation with a canvas, but is in no way required to do so. It is possible to extract the information you want and drive some other visualisation with it. PhysicsJS has a custom renderer ...


4

No. And there is rarely a need for exact physics replication. You mention multiplayer in your tags. Generally, in a multiplayer game, the physics and game logic is performed by one instance, which can be the server hosting the game, or one of the client that hosts the game. Each simulation step, that authority, the server, performs logic update and ...


4

Distance d is the integral of velocity v (calculus). Velocity v is the integral of acceleration a. If you start at velocity s, and you travel for time t, then distance will be d = s * t + 1/2 * a * t^2. You will have two cases. If the object does not reach maxspeed, then you'll have one part where you're accelerating and one part when you're ...


3

It's because of the discreet time and the way you integrate. Because you step time forward at 1/50 of a second you're not guaranteed to hit the actual apex of 4.0, the delta is just not granular enough. (Try setting the delta time to 1/5000 and you'll see that it gets closer to 4, obviously that won't work for your game but it will show you the effect). ...


2

The intent of your code is unclear; adding comments would help us know what you're trying to do, and making sure that we don't have to scroll horizontally would really help. The first thing I notice, though, is that you check your system AND your update it at the same time, which could result in the behaviour you have: For balls A and B, if you inspect a ...


2

I was able to solve this using trig instead of vector math. Here's how it looks as a triangle. Notice that since this is meant for a computer coordinate system, the y+ axis is down. Also the angles are as such: x+ = 0°, y+ = 90°, y- = -90°, and x- = ±180° Additionally, we know that line B's angle is ∠B = -10°. The speeds don't matter since they can be ...


1

I tried to solve it following @david van brink comment. P: intersection point (unknown) S1: car's starting point(2,2 here) S2: canon's starting point(3,12 here) |v1|: car's velocity length (25 here) |v2|: canon ball's velocity length (120 here) a: angle between the car's velocity and the X-axis (10 degrees here... or Pi/18) b: angle between the canon ball's ...


1

Did you try using a different power for the velocity or a combination of powers? Power 3 means that for small speed the friction is almost zero, eg 0.1^3=0.001. Drag from air flow is normally ~v^2 for higher and ~v for low speed so you could use a linear combination av^2+bv. Sliding friction is even independent of speed, so you could add an extra constant ...


1

I was misunderstanding the way vectors in SpriteKit are represented. The solution I used was: dx = (size.width / 2 - ball.position.x) * vel dy = (size.height / 2 - ball.position.y) * vel


1

If two vectors point in the same direction, then their dot product is positive. If the point in opposite directions, there dot product is negative. If they are perpendicular, the dot product is zero. All we need to do is compare a vector from the car to the point and the car's forward vector: bool Car::isInfront(ngl::Vec2 _pos) { ngl::Vec2 fwdVec = ...


1

An oriented bounding box is delimited by six planes (one for each face). A triangle is also delimited by three lines (one for each sides). A naive implementation (which often a good idea to start with) is thus to compute the intersection of any triangle edge with any plane and to check whether at least one intersection occur within an edge of a triangle ...



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