Tag Info

Hot answers tagged

4

The most common approach to this is to detect if the character is standing on a solid surface before allowing them to jump. This restricts players to a single jump since the first jump puts them in the air, then they're no longer on a solid surface, so the next time they try to jump, they can't. For Box2D specifically you can see how to implement that here: ...


3

The Euler method as applied to games is pretty much just the naive Position + (Velocity * TimeSinceLastUpdate) formula I think you were getting at. The other methods (without getting into the calc too much) are just more accurate ways of estimating velocity and position based on multiple simultaneous forces, like friction, gravity, air density, etc. It's ...


2

Stabilizing the delta is not an option as I need different deltas for said effect, so I need to physics to be entirely independent there. Stabilising the delta time is your only option. If we could change the time step of a numerical integration and were guaranteed to get the same results, we could exploit this to get really accurate calculations with ...


2

Welcome to the wonderful world of integral calculus. Speed = distance / time Acceleration = distance / (time * time) So to get the correct answer you need to calculate the integral of your speed, and then the integral of your location. The math can be quite daunting, and in most cases it will be overkill and just make things more complicated. You can use ...


2

I belive there is no friction. Add a physic material with a friction.


1

You have at least one error. This is incorrect: float newDistance = newPointOnPlane.x + newPointOnPlane.y + newPointOnPlane.z It should instead be: float newDistance = glm::dot(newPointOnPlane, newNormal); Because the "distance" of a plane is the distance along the normal to the plane origin, which is given by the dot product between the normal and the ...


1

I don't think there is much you can do to prevent this, because essentially your graph shows you the problem. The physics system has to apply the force according to the tick (or substep) delta, meaning that at some point it is just not possible to update the position of an object independent of the framerate. That is also the reason why you can specify the ...


1

You should be getting a RaycastHit2D object back from your test. You can access the hit info from that to get the distance and other information about the object you hit. Something like the following: RaycastHit2D leftHitInfo = Physics2D.Linecast(leftStart.position, leftEnd.position, layerMask); if(leftHitInfo.collider != null) { ...


1

If it should only hit with left, up, right, and down using Raycasts. Your code will look like this public float[] CheckCollisions() { Raycast hit; float[] collisions = new float[4]; if (Physics.Raycast(transform.position, transform.Vector3.Up, 100.0f, out hit)) collisions[0] = hit.transform.position - transform.position; else ...


1

You probably don't want to use AddForce, and definitely don't use Rotate for physics since it completely overrides the physics engine (and collisions). Use WheelColliders. They're specifically made for this purpose. I've used AddForce in conjunction with WheelColliders with extremely low friction to simulate arcade style hovering vehicles, but anything ...


1

If you want realism, follow the physics of a real car. 4 tires on the ground. Only front two can rotate. For front wheel drive, on each of the two front wheels, I believe rigidbody.addTorque(Vector3) is what you are looking for. But there is a lot more to it. And I am not a mechanical engineer, so you may need an expert in the field to know where the ...


1

The problem with resolving collisions of an entity with voxels in an arbitrary order is that a collision with a voxel edge may be detected before a collision with a face which would have happened earlier. In this diagram a sphere is sliding along a voxel floor (right to left). Its velocity vector (blue) has a downwards component due to gravity. If collision ...


1

You should be moving the car positive X axis instead of the environment around the car negative X axis. Then move the camera with the car.



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