I’d like to start this thread to collect all 2D physics-related needs in one place.
I’ll start:
-
Changing linear and angular velocity in runtime.
Setting linear velocity by code is the best way to make jumps, spawn bullets (with linear trace), arrows (with parabolic trace). Also setting linear velocity is a good way to limit velocity value.
It could be, for example:
physics.set_linear_velocity(dest, vmath.vector3())
go.set(dest, “linear_velocity”, vmath.vector3()) -
Possibility to change masks and groups in runtime.
There are a lot of applications where you need to change mask/group of the physics in runtime. For example, in my current game I have a solid box. Player can move it here or there. But if player punch it - the box slides and crushes everything on it’s way. The best way to make it - change mask of the box just after punching (to move through other object on it’s way).
physics.set_mask(dest, maskValue)
go.set(dest, “mask”, maskValue) -
Creating shapes in runtime.
I’m making platformer game. I use tilemaps. In this case it is necessary to union physic-tiles. To do it I have 40 pre-generated go objects with different rect-shaped physics. And 40 factories for them… and generated go object with 40 factories in it. Just because I can’t create a shape in runtime by code.
Please, implement something like this:
physics.create_shape(dest, ppoints) -
Disabling auto-sleep mode for objects.
Really useful for game main objects. For example, to identify “standing on the ground”. I receive collision_response just until object got in sleep. After that I can’t know - is the object on the ground but sleeps, or object felt or something.
Solution: Switcher in editor, or physics.set_auto_sleep_mode(dest, modeBoolean)
p.s. I was searching for topic like this, but I haven’t found it.