how to add a force to move a rigidbody

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

sorry if this is simple but “add_force” says “Nonexistent function”

all the tutorials and reference material shows a method for 2D not 3D?

how do i apply a force in 3d to a rigidbody node?

thanks

my final code solution (after being given the links) presented as i thought might be useful to give a concise answer

so i just one force on a unit, the most simple

var force_direction = Vector3(10,0,0) # null for no force

func _integrate_forces(state):
    if force_direction:
        state.add_force(force_direction,Vector3(0,0,0))

EDIT: i just realised my code is slightly wrong, as it adds force over and over, you just need to add it once

DarkShroom | 2018-11-10 19:07

:bust_in_silhouette: Reply From: Asoth

hello,
did you called the “state thing”
specific to 3D
previous question 1
previous question 2

you will need someone else to answer why it does work that way

to be honest i’m not too bothered why, i think i can see actually

i guess because it has multiple forces but no easy way yet

i just wouldn’t have got that without asking this question though thanks

DarkShroom | 2018-11-10 15:45