#characterbody3d function alternatives for rigidbody3d
1 messages · Page 1 of 1 (latest)
if you want a response it's best to ask a specific question rather than a general cry for help, most people don't have time to interview you and find out what you want to know, but if they see a specific question they might have time to answer that
characterbody3d function alternatives for rigidbody3d
is_on_floor() can easily be replaced with move_and_collide() with the "test" parameter
Apply downwards movement using the test to make it only SIMULATE the movement.
If it touches something, it is on the floor.
move_and_slide() is redundant. RigidBody already slides off surfaces while moving.
Important to note, you should not use move_and_collide() to actually move the RigidBody. You're supposed to move them by applying forces.
You could try adding a physics material to your rigidbody and upping it's friction.
Oh right, sorry. I'm not entirely sure how much characterbody3d interacts with physics since it uses it's own systems to manipulate velocity.
It's possible that you'd need to set the velocity value yourself in order to stop it from sliding.
I'm not entirely sure if it would act funky and cause the movement scripts and your custom system to "fight" with the velocity if you did that, though.
Oh alright, for a Rigidbody3D you typically wanna move by using forces. .add_force instead of setting velocity, yeah.
If you fiddle with the rigidbody's friction (with physics mat) and damp values you should be able to get it to slide less.
Might also need continuous CD (collision detection), but not necessarily.
If you add a bunch of damp (my game's char has 1 damp atm) it might nto move until you make the force bigger.
It's bit of an act of experimentation.
What does your movement script look like?
Ahh so you are setting velocity manually.
And you are always resetting it to 0 on every physics frame no matter what.
That means if your character were to say slide down a hill, the physics engine wants to change velocity to some number but your script is setting it to a different numbers instead.
Probably causes the physics to be really weird.
By changing velocity manually you probably need to handle things like sliding with math yourself somehow.
I'm not really good with vector math, but maybe somebody else knows.
I do think it's weird that it's sliding, when you are setting it to 0 on every frame. ...oh wait. You are applying force. But applying the velocity as force.
So I guess the faster your player is (higher velocity), the faster they move?
Edit: Or rather, you are applying more force the faster you are moving.
So if you have 100 velocity you are adding a ton of extra speed 60 times per second.
If you have just 10 velocity then you are adding way less 60 times per second.
If it's just physics, not related to movement, I think physics mat also has a setting for bounciness.
Ah. I guess the friction against the ground is acting weird when setting velocity directly.
You can also set that stuff in script I think. If say you wanted physics mat to act differently when moving vs not or w/e.
I haven't messed with that too much though.