Hey!
I'm encountering an issue with accessing a property within a function in my code, and I'm hoping someone can help me troubleshoot it.
Here's the problem: I have a standalone script called VehicleWheel2D.gd that defines a class called VehicleWheel2D. In this script, I'm initializing a variable vehicle to represent a node in my scene, specifically the Car node. I'm able to access vehicle and its properties, such as vehicle.Weight, anywhere in the script without any issues.
However, when I try to access vehicle.Weight from a custom function called calculate_weight_on_wheel() within an instance called front_right_wheel.gd of VehicleWheel2D, it's returning an error "Invalid get index 'Weight' on base 'Nil'". It seems like the variable is not accessible within the function, even though it has been initialized and is accessible elsewhere in the script.
I've checked the scope, timing of function calls, and variable initialization, but I'm still unable to pinpoint the exact cause of the issue. It seems like it might be related to where I'm accessing the variable from or a scoping problem, but I'm not sure.
If anyone has experienced a similar issue or has any insights on how to troubleshoot this further, I would greatly appreciate your input.
Thanks in advance for your help!