0 votes

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 fixedprocess(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".

asked Jan 10 in Engine by flonkopaten (29 points)

1 Answer

0 votes

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)

answered Jan 10 by Zylann (9,766 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.