I am very new to Godot, but I do have some prior experience with coding. I was following a very basic tutorial and the program worked fine until I tired to make my character flip upon turning round. It comes up with "Invalid set index 'flip_h' (on base: 'null Instance') with value type of 'bool'. This, apart from the variable name, is exactly how it works in the tutorial. Anyone willing to help? Here's the full code:
extends KinematicBody2D
Variables
var score: int = 0 #sets coin score to null
physics variables
var speed: int = 200
var jumpForce: int = 600
var gravity: int = 800
var velocity: Vector2 = Vector2() #pixels per second- magnitude AND direction ;)
onready var sprite: Sprite = get_node("Sprite")#Finds child node 'sprite'
warning-ignore:unused_argument
func physicsprocess(delta): #function calls 60 times a second
velocity.x = 0
#condition
if Input.isactionpressed("moveleft"):
velocity.x -=speed
if Input.isactionpressed("moveright"):velocity.x +=speed
#pre defined variable, is just vector2 but x = 0 and y = 1
velocity = moveandslide(velocity, Vector2.UP)
**if velocity.x < 0:
sprite.flip_h = true
elif velocity.x > 0:
sprite.flip_h = false**