0 votes

if i start the scene , it shows this error:

error:non existent function isactionpressed in base nil

extends KinematicBody

func _ready():
pass

stats

var curHP : int = 10
var maxHP : int = 10
var ammo : int = 15
var score : int = 0

physics

var movespeed : float = 5.0
var jumpforce : float = 5.0
var gravity : float = 12.0

camera

var minLookAngle : float = -90.0
var maxLookAngle : float = 90.0
var lookSensitivity : float = 10.0

vectors

var vel : Vector3 = Vector3()
var mouseDelta : Vector2 = Vector2()

onready var Camera : Camera = getnode("Camera")
onready var muzzle : Spatial = get
node("Camera/muzzle")

move

func physicsprocess(delta):

vel.x = 0
vel.z = 0

var input = Vector2()   

#move inputs
if input.is_action_pressed("move_forward"):    <------ error
    input.y -= 1
if input.is_action_pressed("move_backward"):
    input.y += 1
if input.is_action_pressed("move_left"):
    input.x -= 1
if input.is_action_pressed("move_right"):
    input.x += 1

input = input.normalized()

var forward = global_transform.basis.z
var right = global_transform.basis.x

var relativDir = (forward * input.y + right * input.x)


vel.x = relativDir * movespeed
vel.z = relativDir * movespeed

vel.y -= gravity * delta

vel = move_and_slide(vel, Vector3.UP)

if input.is_action_pressed("jump") and is_on_floor():
    vel.y = jumpforce
Godot version 3.3
in Engine by (213 points)

3 Answers

0 votes

Common mistake. In the code above, input.is_action_pressed("move_forward") should be Input.is_action_pressed("move_forward"). I would suggest changing the variable for the Vector2 to a different name (maybe player_input?).

by (2,626 points)
0 votes

thanks for the tipp, so shoud i write now a new variable like this:
var player_input = Vector2 ?

(im pretty new to godot)

by (213 points)
0 votes

thanks you all, now it works

by (213 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 webmaster@godotengine.org with your username.