Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | BlinMaker2077 |
I’am beginer and i started to learning the basics from one czech godot tutorial. I was folowing the tutorial and meanwhile the shoot coding i’ve get the error. It showing the error : Invalid get index ‘speed’ (on base: ‘Node2D’).
i’ve checked if i write the code incorectly but i didn’t found something.
I don’t have any idea how to fix this. So is there somebody who can help me?
I will show the all the codes bellow this text.
extends KinematicBody2D
export var speed = 300
export var gravity = 2000
export var jump = -1000
var move = Vector2()
var directory = 1
var scenastr = preload("res://shooting.tscn")
func _physics_process(delta):
if Input.is_action_pressed("end"):
get_tree().quit()
pohyb.y += delta*gravity
if is_on_floor():
if Input.is_action_pressed("right"):
pohyb.x = -speed
directory = -1
$animatedGuy.flip_h = true
$animatedGuy.play("running")
elif Input.is_action_pressed("right "):
pohyb.x = speed
directory = 1
$animatedGuy.flip_h = false
$animatedGuy.play("running")
else:
pohyb.x = 0
$animatedGuy.play("idle")
if Input.is_action_pressed("up "):
pohyb.y = jump
$animatedGuy.play("jumpUp")
else:
if pohyb.y > 0:
$animatedGuy.play("fall")
if Input.is_action_just_pressed("shooting"):
var shot = scenastr.instance()
shot.position = $vystrel.global_position
shot.speed *= directory
$"../shots".add_child(shot)
move = move_and_slide(move, Vector2(0,-1))
extends Area2D
export var speed = 2000
func _physics_process(delta):
position.x += speed*delta