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

#1

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().

3 Likes

#2

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

0 Likes

#3

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


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

0 Likes

#4

I think you are supposed to use apply_force().

0 Likes

#5

Yes, for dynamic bodies this works. But for Kinematic bodies it has no effect, because their mass are “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.

0 Likes

#6

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

0 Likes

#7

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

0 Likes

#8

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

0 Likes

#9

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.

0 Likes

#10

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

0 Likes

#11

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

3 Likes

#12

Yes, Sven, any input? :smiley:

1 Like

#13

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

7 Likes

#14

That’s great, thanks for considering this!

2 Likes

#15

+1 for this feature :hugs:

2 Likes