#Invalid set index 'flip_h' (on base 'null instance') with value of type 'bool'.

1 messages · Page 1 of 1 (latest)

cinder lichen
#

i get the error when i try to move the player

viscid folio
#

onready var sprite = $Sprite isn't working. Check the name/path to $Sprite

cinder lichen
#

oh is $Sprite suppose to be the name of the sprite?

#

that would make sense

viscid folio
#

yes "Sprite" would need to be the NAME of the object in your tree - not the TYPE of object. If you're coming from Unity this is different than how Unity does it. You can have multiple objects of type Sprite but they all need to have a unique name

cinder lichen
#

ok and no i was following an guide

viscid folio
#

gotcha. Well check the name and path. they have to match. so this object must parent an object (of type sprite) that is named Sprite for it to find it.

cinder lichen
#

ok so now i get "Invalid get index 'flip' (on base: 'null instance')." i change the code in question to onready var sprite = $whitemite

#

im assuming i might be messing it up the sprite thing still cause null means nothing and it talking about the instance

viscid folio
#

null means it can't find "whitemite" in this case

#

take a screen grab/snip of your Scenetree

cinder lichen
viscid folio
#

the W in whitemite is capitol looks like

cinder lichen
#

ah ok

#

must of missed that

viscid folio
#

also you can just click it in your Scene tree and change the name to something else if you prefer

#

but you have to change the code to match - naturally

cinder lichen
#

ok now i get this "Invalid get index 'flip' (on base: 'Sprite')."

#

it seems to be the same error just even further back

#

i changes the code to "onready var sprite = $Whitemite"

#

also it seems to only happen when i try to go to the left

viscid folio
#

$res://Whitemite.png" is not $Whitemite

#

"res://Whitemite.png" is actually a texture

cinder lichen
#

ah ok

viscid folio
#

"res://" means it's loading the texture from your filesystem

#

not the object in your scene tree

#

so var sprite = $"res://" isn't actually a sprite - it's a texture

cinder lichen
#

ok now i get an error even before i run

viscid folio
#

the line of code should be

#

onready var sprite = $Whitemite

#

honestly I don't think you even need the onready

eternal tendon
#

you do

#

$ is an alias of get_node(), so if the node's children aren't in the tree yet (before the parent's _ready), it won't work

viscid folio
#

ah yes. I stand corrected.

cinder lichen
#

ok i still get this error "Invalid get index 'flip' (on base: 'Sprite')."

eternal tendon
#

isn't it flip_h?

#

and flip_v?

cinder lichen
#

flip_h yes here the other part of the code

eternal tendon
#

you typed flip.h not flip_h

cinder lichen
#

oh woops