• 3D
  • 3D rigid body character

Hello, I try to create a player character. I want use a rigid body node, because I don't want to program all the micro-interactions. I had succeed to create a player's behavior with the apply_impulse method, but it isn't perfect, and I hope to find a solution on this forum. My principal problems are : -sometime the players locks, mainly on the edge of the land shape -on the mounted, the player's speed decrease very strong (it's normal, but I haven't idea to keep a nearly constant speed ) -after a running, the player glide -sometime the player go inside the ground

All this problems make me think that the method "apply_impulse" isn't appropriate. I think that the best would be a method similar to "move_and_collide", but "translate" don't work on a rigid body

@Galidraan said: Hello, I try to create a player character. I want use a rigid body node, because I don't want to program all the micro-interactions. I had succeed to create a player's behavior with the apply_impulse method, but it isn't perfect, and I hope to find a solution on this forum.

-sometime the players locks, mainly on the edge of the land shape This happened to me with a capsule blocking in the edge of a cube, smooth your landscape or make bevel to avoid sharp corners.

-on the mounted, the player's speed decrease very strong (it's normal, but I haven't idea to keep a nearly constant speed ) decrease your static ground physics friction and decrease your player rigidBody friction , it should slide

-after a running, the player glide You can apply an additional negative gravity on Y axis when you use add_impulse

-sometime the player go inside the ground Above some speed this can happen. Use a Raycast to floor determine the ground height the player position on Y. When the player Y value is below a treshold use velocity.y =-0.1 to avoid it to go through ground.

The best solution for character controllers is to use KinematicBody to avoid those problems. For example this tutorial should help you create a controller that should work fine. https://youtube.com/watch?v=Etpq-d5af6M

Thank you for your answer, but I realized that your solutions are very difficult to use it and necessitate a lot of adjustment. I tried the set_linear_velocity method, and the result is very mush less random. But when I use it, all the force isn't applicate, and the character don't fall, there are way around this problem? (sorry for my bad English I hope that this message is understandable)

@Galidraan said: Thank you for your answer, but I realized that your solutions are very difficult to use it and necessitate a lot of adjustment. I tried the set_linear_velocity method, and the result is very mush less random. But when I use it, all the force isn't applicate, and the character don't fall, there are way around this problem? (sorry for my bad English I hope that this message is understandable)

Because linear_velocity overrides any force.

Copy and paste code from part one of the Fps tutorial , and you'll got a character controller working :)

docs.godotengine.org/en/3.0/tutorials/3d/fps_tutorial/part_one.html

9 days later

After much effort I abandoned the idea of using a rigid body. I think that today, we can't create a complex character with the 3D_rigid_body, this node hasn't enought useful method for this. We can surely create them, but I haven't the level. Maybe in the future, this node will be more complete. Thank for your support. But if someone has succeed to use a rigid body for his character, say it I'm interested.

Why not use a KinematicBody?

I’ve found it’s way easier to use KinematicBody for player/characters. The overhead is way less than using a RigidBody (in my opinion) and there’s plenty of material to use for reference. There’s the KinematicBody demo, the FPS tutorial (disclaimer: I wrote most of it), the Platformer demo, a great tutorial series by Jeremy on YouTube, and much more.

If you really want to use a RigidBody, I would suggest looking at the dynamic character demo. I think it’s the same as the Platformer demo, but instead of using a KinematicBody for the player, it uses a RigidBody.

@Galidraan said: After much effort I abandoned the idea of using a rigid body. I think that today, we can't create a complex character with the 3D_rigid_body, this node hasn't enought useful method for this. We can surely create them, but I haven't the level. Maybe in the future, this node will be more complete. Thank for your support. But if someone has succeed to use a rigid body for his character, say it I'm interested.

Godot is managing a character controller almost the same way it's done elsewhere. Why don't you follow this tutorial video, it's exactly what you want a character controller https://youtube.com/watch?v=-CudxS6EeNA

I use RigidBody for my character but it's not a human but a...jumping disc....So I need more physics interactivity...you can use modes in RigidBody node - rigid - static - character - kinematic so I think RigidBody in Godot is a very useful and sophisticated .....what unfortunately is missing are good examples of these modes ......until when the Bullet physics engine will be fully integrated with Godot engine (Godot 3.2 ?) so the collisions ,etc. will be at a high level ;)

@Bishop said: I use RigidBody for my character but it's not a human but a...jumping disc....So I need more physics interactivity...you can use modes in RigidBody node - rigid - static - character - kinematic so I think RigidBody in Godot is a very useful and sophisticated .....what unfortunately is missing are good examples of these modes ......until when the Bullet physics engine will be fully integrated with Godot engine (Godot 3.2 ?) so the collisions ,etc. will be at a high level ;)

I don't understand why rigidbody can become a static or kinematic physic object ? There is already static and kinematic nodes, what is the advantage of RigidBody providing those functionalities ? At run time change the RigiBody node to become static or kinematic , bu i don't see any advantage.

MODE_RIGID = 0 — Rigid body. This is the “natural” state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code. MODE_STATIC = 1 — Static mode. The body behaves like a StaticBody, and can only move by user code. MODE_CHARACTER = 2 — Character body. This behaves like a rigid body, but can not rotate. MODE_KINEMATIC = 3 — Kinematic body. The body behaves like a KinematicBody, and can only move by user code. ....from docs

The advantage is , that you have a bigger control over the behavior of the object/character in the game.....with a RigidBody node you do not control rigidbody directly but only forces...if you need directly access to physics, use integrate_forces().....by set custom_integrator() = true ( to override the default physics behavior ) , then air friction and gravity will be disabled and you can write your custom forces.

....here's something from QA http://godotengine.org/qa/18344/rigidbody-in-kinematic-mode-vs-kinematicbody

Ok, thank you, for I will used a kinematic body, but maybe one day I will change my choice. Thank you every body :wink:

11 days later

Sorry to re-open the subject, but I use the Schuster's video technique, it was worked good, but today, I have modify some thing in my scene and now the character often hangs several second. I can not put things back as before. Now the displacement is uncomfortable, and isn't playable.

Hello, ....what's the character setup...node tree hierarchy? ....what the Rigid body mode? ....what do you use to move the character?

@Galidraan said: Sorry to re-open the subject, but I use the Schuster's video technique, it was worked good, but today, I have modify some thing in my scene and now the character often hangs several second. I can not put things back as before. Now the displacement is uncomfortable, and isn't playable.

Can you post a zip package with a minimal demo so we can figure out what is wrong ?

6 days later

@Galidraan said: Ok this is a version with no texture, and a micro-map, be careful not to fall https://drive.google.com/file/d/1mfLRdFN_IrOM_i1fAmXkTa9apGA164qr/view?usp=sharing I think, that you can see quickly the bug

The root node of your character should be KinematicBody instead of Spatial, there is bugs if the root node is not a physic node.

I made a tps template on top of your game level. The game runs fine, but the player controllers do hyper jump on floor big angle slopes :D KinematicBody doesn't like distance change with move_and_slide() on big angle slopes.

This works fine velocity.y += delta * gravity

This makes hyper jump on slopes velocity.y += delta * gravity if !is_on_floor(): velocity.y = velocity.y *1.5

The project GitHub download link :

https://github.com/DevMagicLord/Godot3/tree/master/bugs

You can submit a bug on Godot GitHub about move_and_slide() bug on your game level.

I think there is two bugs : is_on_floor() is some sort of hack and can't work because there is micro contact variation when your floor is level is not planar but a terrain mesh with slopes. Raycast is the best way to detect floor. move_and_slide() hyper jumps because there is some parameter value change when it is on some slope


Perhaps you should use move_and_collide() instead.

This is a fundation critical bug, i will submit it to GitHub.