Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | theMX89 |
if i start the scene , it shows this error:
error:non existent function is_action_pressed 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 = get_node(“Camera”)
onready var muzzle : Spatial = get_node(“Camera/muzzle”)
#move
func _physics_process(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