how do i move a rigidbody

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By flonkopaten
:warning: Old Version Published before Godot 3 was released.

I wrote a question related to this question earlier today, but because this is new topic i ask on a new question.
I want to make a simple game with a cube moving arround and colliding with some walls.
the movement behaviour i found was good i made in this script.
func _fixed_process(delta):

if (Input.is_action_pressed("ui_up")):
	speed = speed - .5
elif (Input.is_action_pressed("ui_down")):
	speed = speed + .5
if (Input.is_action_pressed("ui_left")):
	rotate_y(-delta/.8)
elif (Input.is_action_pressed("ui_right")):
	rotate_y(delta/.8)
translate(Vector3(0,0,delta*speed))

Very simple!, now the thing is that this dont seem to work well on rigidbody when it comes to colliding. I serached on google but very hard to find tutorials.
On my other question i was told not to use translate, i would use forces for this.
But how? can some one give me a clue or a ready script to afford the same movement by using “forces”.

:bust_in_silhouette: Reply From: Zylann

RigidBody is a physics node that moves according to “realistic” physic rules (like gravity and forces), so it won’t move manually like you do in your code. You can make it move by applying a force with set_linear_velocity, or use another node like KinematicBody and check yourself for collisions (I think there are functions on this node to move by handling collisions at the same time but I don’t remember, you should check the doc)

Ok thanks for the answer, i think then it might be better i use kinematicbody instead, just need to learn how to fix the colliding. Thanks

flonkopaten | 2017-01-10 17:18