My CharacterBody2D not showing. In a control scene script i type: @onready var farm_hero = $Character/FarmHero func _process(delta): if character == 1.1: farm_hero.visible = true
but when i start the game and click the button so that the ‘character variable’ be ‘1.1’ and change to main scene but the characterbody2d dont show. Please help
you should not combine @onready var farm_hero = $Character/FarmHero func _process(delta): if on one line
and also make sure you can see it in the editor
@onready var farm_hero = $Character/FarmHero
func _process(delta):
if character == 1.1:
farm_hero.visible = true
var character:float = 0
func _on_farm_guy_pressed():
character = 1.1
print(character)
get_tree().change_scene_to_file("res://GameScene/Gamescene.tscn")
idk what pic do u want but this is the code when the button is pressed the scene change and the value is 1.1 and if the value is 1.1 the characterbody need to show
func _process(delta):
if character == 1.1:
farm_hero.visible = true
You will set visible property at each frame while character equal 1.1.
For your problem, I think, try to use signals for change visible property of your farm_hero.