0 votes

https://www.youtube.com/watch?v=-CudxS6EeNA
i try this tutorial.and i write this code.
but i can not move left and back.
forward and right is work.
What's wrong?

extends KinematicBody
var gravity = -9.8
var velocity = Vector3()
var camera
const SPEED = 6
const ACCELERATION = 3
const DE_ACCELERATION = 5


# Called when the node enters the scene tree for the first time.
func _ready():
    camera = get_node("../Camera").get_global_transform()
    print(camera.basis[2])
    print(camera.basis)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#   pass

func _physics_process(delta):
    var dir = Vector3()

    if Input.is_action_pressed("move_fw"):
        dir += -camera.basis[2]
    if Input.is_action_pressed("move_fb"):
        dir += camera.basis[2]
    if Input.is_action_pressed("move_r"):
        dir += -camera.basis[0]
    if Input.is_action_pressed("move_l"):
        dir += camera.basis[0]

    dir.y = 0
    dir = dir.normalized()

    velocity.y += delta * gravity

    var hv = velocity
    hv.y = 0


    var new_pos = dir * SPEED
    var accel = DE_ACCELERATION

    hv = hv.linear_interpolate(new_pos,accel * delta)

    velocity.x = hv.x
    velocity.z = hv.z

    velocity = move_and_slide(velocity,Vector3(0,1,0))

Also, what is 3 × 3 matrix ()? I tried to print.

camera = get_node ("../ Camera"). get_global_transform ()
print (camera.basis)
print (camera)

((-1, -0, -0), (-0, 0.951692, 0.307056), (0, 0.307056, -0.951692))
-1, -0, -0, -0, 0.951692, 0.307056, 0, 0.307056, -0.951692-0, 6.91487, -10.1349

where is difference this?
i think this section is value of rotation.
but what are the other section of question mark?
((rotation,?,?) (?, rotation,?) (?,?, rotation))

please help

in Engine by (203 points)

First of all check the names of your actions.

Then if you want to understand matrices read this explanation in the godot documentation.

1 Answer

0 votes

thanks.i missed input setting.sorry.

by (203 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.