applying a sudden impulse to a CharacterBody3D in Godot 4

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cupofdirtfordinner

man, I’ve been having quite a bit of trouble with this. Every time I google it it gives me results for either 2D, RigidBodies, 3.x instead of 4, or some combination of the three. I resorted to using ChatGPT and it told me to “just use a RigidBody class instead”, which of course isn’t really in the cards, and then gave me a code snippet for 3.x and hallucinated a function called push_ray_impulse(). weird stuff.

anyways, no more exposition, I just need to create a sudden impulse or a force of some kind to a CharacterBody3D.

I’m imagining like a vector 3 for direction and a float for power or something like that, but really it doesn’t matter how it works as long as it does work. My use case is for pushing off a wall upon wall jumping in a 2.5d platformer (as in a 3D world but moving in 2 axis) after wall-jumping, if it’s of any help. thanks

Have you not considered just adding the desired force to the velocity, e.g. like jumping? The docs have examples on how to use a CharacterBody:

CharacterBody3D — Godot Engine (stable) documentation in English

spaceyjase | 2023-06-24 17:36