Godot Version
Godot 4.2.2
Question
I can’t get the UI to work when I want to place a tower in my game, I wanted it to be able to fill in where my mouse is with a tower to show exactly where the tower is and I am having trouble with this specific line of code, I was following a tutorial but it was from an old version of Godot, and the code that they put in doesn’t work. Here it is:
extends Node2D
var map_node
var build_mode = false
var build_valid = false
var build_location
var build_type
func initiate_build_mode(tower_type):
build_type = tower_type + “tier_1”
build_mode = true
get_node(“UI”).set_tower_preview(build_type, get_global_mouse_position())
func _ready():
map_node = get_node(“Map1”) ## Turn this into variable based on selected map
for i in get_tree().get_nodes_in_group("build_buttons"):
i.connect("pressed", self, initiate_build_mode, [i.get_name()])
func _unhandled_input(event):
pass
func update_tower_preview():
pass
func cancel_build_mode():
pass
func verify_and_build():
pass