Godot 3.5.3
The kinematicbody is not responding to my script
How to make it move?
Here’s my script so far
local Player = {extends = "KinematicBody",}
local speed = 7
local fall_acceleration = 5
local velocity = godot.Vector3 ()
local direction = godot.Vector3 ()
function _ready(self)
local head = nil
head = self:get_node("Camera pivot")
end
function _physics_process(self, delta)
local input_dir = godot.Vector3()
local input = godot.Input
if input: is_action_pressed ("ui_up") or input:is_key_pressed(godot.KEY_W) then
input_dir.z = input_dir.z -1
end
if input: is_action_pressed ("ui_down") or input:is_key_pressed(godot.KEY_S) then
input_dir.z = input_dir.z +1
end
if input: is_action_pressed ("ui_right") or input:is_key_pressed(godot.KEY_D) then
input_dir.x = input_dir.x +1
end
if input:is_action_pressed("ui_left") or input:is_key_pressed(godot.KEY_A) then
input_dir.x = input_dir.x - 1
end
local direction = self.global_transform.basis:xform(input_dir)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
if not self:is_on_floor() then
velocity.y = velocity.y - fall_acceleration * delta
else
velocity.y = 0
end
direction = self.global_transform.basis * input_dir
velocity = self:move_and_slide(velocity,godot.Vector3(0, 1, 0))
end