I want to create a class to hold some data. For the sake of the question, I want a Vector4 class. How would I build this with GDscript.
It seems that Custom Resources is the only method which has worked to an extent.
export(float) var x = 0
export(float) var y = 0
export(float) var z = 0
export(float) var w = 0
return sqrt(x*x + y*y + z*z + w*w)
This is all fine. But if I try to add a method to create a Vector4 from a Vector3 it gets errors about cyclic reference.
func from_v3(v: Vector3):
return Vector4.new(v.x, v.y, v.z, 0)
This seems to be resolved if I use get_script(), but this wouldn't work in a static factory method.
Is there a better method? Also being able to override equality, or do something like Vector4.Up would be nice.
Alternatively, I've seen some people use dicts for structs but that seems to lose a lot. Thanks