Hi everybody,
I've got an Angelscript class with get/set accessors. All the documentation uses integers to demonstrate this, but I'm using a Vector3 value-type object.
shared abstract class Actor
{
private Actor_cpp@ cpp_obj;
void Update() {}
Vector3 local_position
{
get const { return cpp_obj.GetLocalPosition(); }
set { cpp_obj.SetLocalPosition(value); }
}
}
For the most part it's working fine, it's possible to get the local position, change the position, and then set it like so:
Vector3 pos = local_position;
pos.x = 0.0f;
local_position = pos;
The problem comes with setting the individual components of the vector - for example,
local_position.x = 0.0f;
Will give an error when compiling that script:
ERR : Expression is not an l-value
Which makes sense to me - I've not given those individual components set functions. The problem is that I don't know how to declare the set function. It can't be a get/set in the Vector3 class since they don't necessarily belong to an Actor, and since the documentation only uses integers to demonstrate get/set accessors I don't know what a setter on the individual components inside the Actor class would look like, if such a thing is possible.
It's not the end of the world if this isn't possible. As I said, it is possible to change the position by creating a Vector3, modifying that and using it for the setter, but writing scripts would be a lot nicer if that wasn't necessary.