HELP!!! Invalid call. Nonexistent function 'initialize' in base 'StaticBody2D'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Damoyacxnt

so I have been following a tutorial on building a farm sim,(https://www.youtube.com/watch?v=WtlJgdCPJ4k&ab_channel=SmallNap)
I followed his directions to a T and despite his working mine is not as I keep getting a non-existant func “initialize” despite the func being called in a child script. I am fairly new to coding and have tried every which way to solve this issue to no avail. here is the error “Invalid call. Nonexistent function ‘initialize’ in base ‘StaticBody2D’.”
I will also attach the script bellow the first two being from the Base Scene and the last from the scene I am trying to instance.
Thank you in advance to anyone that can help!

  • var _crop_data = {“pk”: 1,
    “object_name”:“Weed”,
    “phase_days”: [1,2,2,2,INF],
    “current_phase”: 0,
    “day_of_current_phase”: 0,
    “crop_age”: 0}

  • func _input(event):
    if event.is_action_pressed(“Plant”):
    var crop_path = “res://DrugLordSim proj/Crops/Weed.tscn”
    var crop = load(crop_path).instance()
    crop.initialize(_crop_data)
    crop.global_position = tile_pos_infront_of_player * 32
    add_child(crop)

  • func initialize(_crop_data):
    .initialize(_crop_data)
    phase_days = _crop_data.get(“phase_days”)

initialize() is called in several places of your code here. Which one is failing?

Zylann | 2020-09-18 12:50

it is the line:
crop.initialize(cropdata)

Damoyacxnt | 2020-09-18 13:01

Woo I managed to fix it now thanks for a quick reply

Damoyacxnt | 2020-09-18 13:26

You should add the solution to this question so that any other user who encounters a similar problem in future can get a solution here :slight_smile:

Scavex | 2020-09-18 17:53