Godot Version
4.2.1
Question
we have trying to fade and hide rooftops in a top-down game and we are using codes from this tutorial (http://www.youtube.com/watch?v=hW8f0hkhBXs) but apparently this is godot 3.5 and it’s not in godot 4, commands like self.connect are not in the godot 4. this is the entire code:
class_name TransformArea2d
extends Node
func _ready():
var _error= self.connect(“body_entered”,self,“_on_body_entered”)
var _erroro= self.connect(“body_exited”,self,“_on_body_exited”)
func _on_body_entered(body):
if player.is_player(body):
var parent=get_parent()
_transform(parent)
func _on_body_exited(body):
if player.is_player(body):
var parent=get_parent()
_untransform(parent)
func _transform(_node):
pass
func _untransform(_node):
pass
also this is the fade class:
extends TransformArea2d
func _transform(node):
_fade(node)
func _untransform(node):
_unfade(node)
func _fade(node):
if _can_fade(node):
node.modulate.a= 0.5
else:
for child in node.getchildren():
_fade(child)
func _unfade(node):
if _can_fade(node):
node.modulate.a= 1
else:
for child in node.get_children():
_unfade(child)
func _can_fade(node):
return “modulate” in node
and this the hide class:
extends TransformArea2d
func _transform(node):
node.hide()
func _untransform(node):
node.show()