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