Godot Version
4.6.3
Question
I have a simple resource I was hoping to use to store simple information about my Active Ragdoll character, such as limb angles for the controllers. From what I can tell, I’ve created a quite boilerplate custom resource class, included below:
using Godot;
namespace Ragdoll.Data
{
[GlobalClass]
public partial class RagdollData : Resource
{
[Export] public float LeftThighAngleDegrees = 30;
[Export] public float RightThighAngleDegrees = -30;
public RagdollData() { }
}
}
but whenever I try to assign to a property of its type (Ragdoll.Data) I get errors stating the item being passed is a resource - even if I’m adding a RagdollData class such as the following:
[gd_resource type=“Resource” script_class=“RagdollData” load_steps=2 format=3 uid=“uid://bqbopffeduutm”]
[ext_resource type=“Script” uid=“uid://co3b7e07mdpie” path=“res://RagdollData.cs” id=“1_j45sw”]
[resource]
script = ExtResource(“1_j45sw”)
metadata/_custom_type_script = “uid://co3b7e07mdpie”
This is the field I’m trying to set it to, initially it was just a [Export] public RagdollData RagdollConfig but it snowballed into the following just trying to get this mf resource to load:
private RagdollData _ragdollConfig;
[Export]
public Resource RagdollConfig
{
get => _ragdollConfig;
set
{
if (value == null)
{
_ragdollConfig = null;
return;
}
// 1. Check if it's already the correct C# type
if (value is RagdollData directCast)
{
_ragdollConfig = directCast;
return;
}
// 2. If the bridge is broken, fetch the raw instance from memory using the correct method:
ulong instanceId = value.GetInstanceId();
GodotObject rawObj = GodotObject.InstanceFromId(instanceId);
if (rawObj is RagdollData marshaledCast)
{
_ragdollConfig = marshaledCast;
}
// 3. Fallback: Load manually WITHOUT telling GD.Load it's a RagdollData
GD.Print("[Ragdoll] Inspector assignment failed. Attempting generic file fallback...");
Resource genericResource = GD.Load<Resource>("res://RagdollLimbConfig.tres");
if (genericResource != null && genericResource is RagdollData fileCast)
{
_ragdollConfig = fileCast;
GD.Print("[Ragdoll] Fallback manual load succeeded!");
}
else
{
GD.PrintErr($"[Ragdoll Error] Fallback failed. Object in file is: {genericResource?.GetType().FullName}");
}
}
}
Can anyone advise me on where I’m going wrong? I’d just like to load a customer resource from the editor but if there’s a more elegant solution to storing angles for various stances and walk cycles I’d love to know that as well!