d works but w a and s will not work unless i press down d and the other key i need help fixing this problem

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By joeyjks

extends KinematicBody

export var speed = 10
export var acceleration = 5
export var gravity = 0.98
export var jump_power = 30

onready var head = $head
onready var camera = $head/Camera

var velocity = Vector3()

func _physics_process(delta):
var head_basis = head.get_global_transform().basis

var direction = Vector3()
if Input.is_action_pressed("move_forward"):
	direction -= head_basis.z
elif Input.is_action_pressed("move_backward"):
	direction += head_basis.z

if Input.is_action_pressed("move_left"):
	direction -= head_basis.x
elif Input.is_action_pressed("move_right"):
	direction += head_basis.x
	direction = direction.normalized()

	velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)

	velocity = move_and_slide(velocity)
:bust_in_silhouette: Reply From: Chafmere
direction = direction.normalized()

velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)

velocity = move_and_slide(velocity)

If your code entry Above matches what’s in your game then this section, which sets the motion, is indented to be under your elif condition for “move_right”. You need to un indent it.

Think you so much!

joeyjks | 2020-09-17 04:12