#Can't jump
1 messages · Page 1 of 1 (latest)
Could you show an example of trying to get a rigidbody to jump and it not working?
i.e. show the scripts and nodetree and anything else relevant
We can't help much more than pointing you to the platformer tutorial without any more details
CharacterBody3D's better for character control purposes.
Or general control. RigidBodies are CharacterBodies but with much less control (like no Move and Slide)
Character body 3d?
What's that?
Search up character in the node search box
What does it do?
extends RigidBody3D
var on_ground = true
func _process(_delta):
if Input.is_action_pressed("Left"):
apply_force(Vector3(-10,0,0))
elif Input.is_action_pressed("Right"):
apply_force(Vector3(10,0,0))
if Input.is_action_pressed("Jump"):
if on_ground == true:
apply_force(Vector3(0,400,0))
on_ground = false
Issue is, I'm not sure how to detect when on ground
Haha, I'm pretty sure characterbody does that for you
so there is no way for a rigidbody to detect ground?
You can but you'll need to code it yourself
simple or no?
Well there's a whole spectrum
you can do some pretty simple detection, but it will work weird in some edge cases
doing proper ground detection is more complicated
💀
Hm, rigidbody does handle its own collision though
Is there a particular reason you want rigidbody specifically?
I want it to collide with things
Characterbody collides too
oh sweet
I'd reccomend going to your rigidbody3d, right click, change type, and searching characterbody3d
I'll have to look up what a character body does
It's got a special move_and_slide() function you call that handles collision and everything for you
It allows you to specify an up vector and has a variable telling you if it's on the ground iirc
Alright I'll have to see if that works, cheers
yeah
you just call any of these functions if you're using a characterbody3d
super useful
https://docs.godotengine.org/en/stable/classes/class_characterbody3d.html here's the full docs ofc
Inherits: PhysicsBody3D< CollisionObject3D< Node3D< Node< Object A 3D physics body specialized for characters moved by script. Description: CharacterBody3D is a specialized class for physics bodies...
Good luck!!
BTW if this question is solved, please mark it as such