Setting linear velocity and angular velocity of a kinematic body (#4170) (SOLVED)

These puppies are not available for kinematic bodies and I miss them!

set_linear_velocity()
set_angular_velocity()

When dynamic bodies collide with kinematic bodies, forces don’t work as they should when “teleporting” kinematic objects using set_position().

4 Likes

I’m not sure I understand what it is you are requesting? Could you explain a little bit more?

Exposing these two methods from Box2D, allowing bodies to move naturally within the physics world:


https://jesse.tg/Box2D-Docs/classb2_body.html

I think you are supposed to use apply_force().

Yes, for dynamic bodies this works. But for Kinematic bodies it has no effect, because their mass is “infinite”. In Box2D you can move Kinematic bodies with SetLinearVelocity, which allows natural interaction with dynamic objects. A typical example for this is a moving platform in a platform game.

Ah, I think this would be tricky to add. @sven any input?

If apply_force() doesn’t work on kinematic object, then how else player is supposed to move with physics system?

Kinematic objects are moved using go.animate() and go.set_position(). Dynamic objects are moved using apply_force.

That mean’s kinematic body isn’t movable with physics (colliding doesn’t count)?
What if I want player to be a tire (from movie Rubber :smiley: ) and I want it to move by physically rolling?
As far as I’ve tried physics in Gamemaker it had all Box2d api, so that seems weird that defold doesn’t have.

Yes, the reason I started this thread is to see if there is a way to add this functionality.

+1 for this feature. It would be great to have this.

3 Likes

Yes, Sven, any input? :smiley:

1 Like

Hey now :slight_smile:

I like the feature, but I think we would need to have a design meeting and think about how it would impact other systems (ways of updating the positions etc). I don’t think I can answer any more specific than that, part because I’m not an expert on the physics internals. :stuck_out_tongue:

Adding an issue for this so we can discuss it internally: #4170

8 Likes

That’s great, thanks for considering this!

2 Likes

+1 for this feature :hugs:

3 Likes

@sven something changed with this feature?

No sorry no change yet.

I am making an extension for Box2D, this functionality will be available in it.

2 Likes

Wow! Will the extension use game objects and collision shapes from the editor, or will it be “code only”?

Code only. You will have to setup some interaction between game objects and the extension. Plus at first not all functionality will be available, but people will be able to modify and extend the extension.

3 Likes