+1 vote

I am writing a physical platform game that every character is a rigidbody. I want some bounce between them so I change the physical material of them and set bounce to 1. And I don't want characters to bounce on ground so I set ground's bounce to -1. This works as expected.
For moving platforms, I am having some issue that characters slide or drift on horizontally moving ones slightly. I find that the sync_to_physics of kinematicbody perfectly fix this. However, I cannot set the bounce of kinematicsbody and they appear to be always 0, so characters with bounce of 1 would bounce on them. Rigidbody in kinematics mode can have custom bounce, however there's no sync_to_physics for them and thus the drift issue. Is there a way to fix both?

in Engine by (29 points)

2 Answers

+1 vote
Best answer

By looking into the C++ code of RigidBody2D, I found this:

PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());

This translated to gdscript is

Physics2DServer.body_set_param(get_rid(), Physics2DServer.BODY_PARAM_BOUNCE, bounce)

Tested and it works for all types of PhysicsBody2D. Now I can have a KinematicBody2D that has custom bounce or friction (and many other physics properties that seem to be exclusive to RigidBody).

by (29 points)
0 votes

kinematic body does not use physics material so you have to implement the bounce your self or post the code here and maybe we can find the problem and fix it

by (104 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.