This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes
ar gravity = 9.8

var location = Vector3()
var capncrunch = Vector3()
export var speed = 7
export var jump_height = 9
var velocity = Vector3()

func getinput():
velocity = Vector3()
velocity.x += 1
if Input.isactionpressed('uileft'):
velocity.x -= 1
velocity.z -= 1
if Input.isactionpressed("ui_backwards"):
velocity.z += 1
velocity = velocity.normalized() * speed

func physicsprocess(delta):
velocity = move
andslide(globaltransform.basis.xform(capncrunch), Vector3.UP)

if Input.is_action_just_pressed("jump"):
    if is_on_floor():
        capncrunch.y = jump_height

if not is_on_floor():
    capncrunch.y -= gravity * delta
in Engine by (58 points)

Means do you want to make a fps type game in Godot?
Then you can search for Garbaj fps series. It will teach you
how to make a fps in Godot.

2 Answers

0 votes

Change all velocity.x, velocity.z to velocity.basis.x, velocity.basis.z

by (50 points)
0 votes

Each object has both a local and global transform (transform and global_transform, respectively). Which one you use depends on various circumstances, but the transforms are what you need. Assuming you are executing a script from within the object class itself, you can get the local direction vector with:


and the global direction vector with:


Then you can use move_and_collide or move_and_slide with this vector.

by (595 points)
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.