[SOLVED] Collision Response for Kinematic

Hi everyone,

Does anyone know a proper way to do collision with kinematics? Currently, I am doing ray-casting every update(I am shooting 6 rays starting from the origin of my spatial) but that doesn’t work well when the ray is not seeing anything but a corner of the spatial is in terrain. Thanks in advance.

Note: 90% sure bullet vehicles are already doing this sort of ray casting. So there is a chance you are reinventing the wheel. (pun intended hah)

2 Likes

Ah, I will try out bullet vehicles then and see how that goes.

https://javadoc.jmonkeyengine.org/v3.3.2-stable/com/jme3/bullet/control/VehicleControl.html

1 Like

Wait, it seems that the vehicle controller is for wheeled objects. I’d assume I would need to apply a central force to make it go up right? But then I’d be back to where I was before(I’m using kinematics now). If I set to kinematic mode then I don’t think the collision response would work.

Basically, I want the collision detection of dynmaic objects, but the control that I have (no other forces, ect) of kinematics

To me, “collision response” is an ambiguous term.

Kinematic bodies detect collisions, and they report them just like dynamic bodies do, via collision listeners added to the PhysicsSpace. Properly speaking, the feature that prevents rigid bodies from intersecting is “contact response,” which is a different thing.

Contact response for kinematic bodies goes one way only: the kinematic object pushes dynamic bodies out of the way, but not vice versa. There’s no contact response between kinematic bodies and static bodies or other kinematic bodies. I don’t know an easy way to simulate contact response between kinematic bodies.

For a vehicle, I suspect what you want is either a VehicleControl (if it’s supported by a surface) or else a dynamic RigidBodyControl with some stabilization added (if it’s flying or orbiting).

While it’s true that VehicleControl simulates wheels, it does so (as Paul pointed out) using raycasts. The wheels of a VehicleControl have no solidity and no momentum. If you’re simulating a hovercraft, you can easily make the wheels invisible. The classic example of this is TestHoveringTank, which simulates a hovercraft traveling over rough terrain:
jmonkeyengine/TestHoveringTank.java at master · jMonkeyEngine/jmonkeyengine · GitHub

Note: outside of science fiction, hovercraft generally have a flexible “skirt” which enables them to pass over small obstructions. Stabilization is provided by the cushion of air trapped in the skirt.

1 Like

Thank you very much for the info! I must use kinematics, however, since my player will walk on it. I just found out about something called testSweeps for collision detection and they work great! Am marking this as solved as testSweeps allow for collision detection.

2 Likes

Are you writing a platformer?

No, I plan to allow the player to visit different planets in a spaceship and I would like for them to be able to walk inside the ship while it is traveling

1 Like

will we do the same with train?

I think so… if you need the player to walk in the train, be aware that the code is very buggy, though. Simply remove the flying stuffs