![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | D.Q.Li |
I am learning Godot through HeartBeast’s tutorial and get this error while using the exact same code.
EDIT: sorry I accidentally post it before putting up the code.
extends Node2D
func _process(delta):
if Input.is_action_just_pressed(“attack”):
var grassEffect = load(“res://Action RPG Resources/Effects/grass effect.gd”)
var Grasseffect = grassEffect.instance()
var world = get_tree().current_scene
world.add_child(grassEffect)
queue_free()
I saw the solution in another similar question but the method does not apply to me. Instead it says “invalid type in function ‘add_child’ in base Node2D, the object-derived class of argument 1 (packed scene) is not a subclass of the expected argument class”
“invalid type in function ‘add_child’” you aren’t trying add Grasseffect
instead grassEffect
? you needed understand what variable is for what.
Moreus | 2023-03-10 11:13
you could link tutorial and use code as code not text
Moreus | 2023-03-10 11:16
yeah thats the reason, thank you very much
D.Q.Li | 2023-03-10 11:22
Animal welfare is an important issue that affects us all. It’s not just about being kind to animals, but also about preserving the balance of nature and protecting the environment for future generations. Please checkout: Animal Welfare
kitticpet | 2023-03-11 07:13