Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
https://youtu.be/SJuScDavstM?si=uXGaVc1ULLI-fvQq
Thanks :)
My problem is regarding two CharacterBody3D objects.
I want to avoid one from standing on top of the other...
In physics_body_3d.cpp, there is a function (CharacterBody3D::_set_collision_direction) that looks through all the collisions and decides whether they are a floor, wall or ceiling.
This line will make sure the collider is not a CharacterBody3D:
Here it is in context
if (motion_mode == MOTION_MODE_GROUNDED) {
// Check if any collision is floor.
// CharacterBody3D is not floor
if (Object::cast_to<CharacterBody3D>(ObjectDB::get_instance(collision.collider_id)) == nullptr) { // <------- ADD THIS LINE
real_t floor_angle = collision.get_angle(up_direction);
if (floor_angle <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) {
r_state.floor = true;
if (p_apply_state.floor && collision.depth > floor_depth) {
collision_state.floor = true;
floor_normal = collision.normal;
floor_depth = collision.depth;
_set_platform_data(collision);
}
continue;
}
} // <------- ADD THIS AS WELL
... the rest of the function can be left alone [/code]
https://docs.godotengine.org/en/stable/classes/class_characterbody3d.html#class-characterbody3d-property-platform-floor-layers
But how do I use this variable? If I could remove the character collision from the platform layers, I believe might make the character not stand on top of others.
Edit: Managed to change that on the inspector, and disable for other characters. Characters still can stand on top of each other, but one character no longer moves another when moving.
If pass-through, look into setting the collision layers & masks of the characters to not interact with each other
If you want them to slide off, split your collision capsule into two stacked on top of each other (like a snowman), and set the friction of the top capsule to zero, and anything that does collide with it should slide right off.
For more granularity, consider a cylinder with a sphere on the top and bottom.
... or depending on your collision detection needs, a vertical pair of spheres.