0 votes

Hello, i am new to Godot engine and i try to make a simple game with just a cube and a few walls. The cube is my character, and i use this script to make the movement.
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 but works just like i want it to.
My problems is when i move this cube into my wall wich is like this :staticbody and the children is meshinstance and collisionshape.

The cube (character) is rigidbody with children meshinstance, collisionshape and a camera.

When move the character into the wall the wall blocks but not totaly, i mean if you still push the button it slowly goes through the wall.
How can i fix this?

in Engine by (30 points)

Hi,

I got this problem with my player spawning above the floor, when contact with the floor, player slowly goes through it and stop after fews seconds. Sadly, I don't remember how i wad fixing that ! You can activate debug collisions and try to check the normals and try to a simple floor test. If you want you can put your project here, I can check.

1 Answer

0 votes

You should not move a rigid body with translate, those need to be moved by forces and controlled by the engine, look at the Platformer 3D demo to see how to simulate movement on a rigid body by controlling the body physic state.

by (7,934 points)

ok thanks, i will check that.

any advice on similar movement script with using forces, would be nice :) i try check it myself but a bit new to this :)

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.