Storing Vector3 on an item

So, I’m trying to make an elevator. Each elevator door pane should contain a property with its position when closed, so that it always closes to the same position.

Positions are referenced using the Vector3 object, so I tried to set them like so:

this.doorPanes.forEach((pane) => {
    pane.setProperty('closedPos', pane.transform.position);
});

However, upon closer inspection, CoSpaces can only store properties as strings, and attempting to store anything else as a property will cause it to be casted to a string.

What is the simplest way to have per-object Vector3 properties?

I’d suggest keeping it saved as a string, then, when needed, splitting it out into an array, the elements of which you can reference for the x/y/z; e.g:

doorPane.input.onClick(()=>{
    let pos = doorPane.getProperty('closedPos').split(','); // array
    doorPane.transition.moveTo(
        new Vector3(pos[0],pos[1],pos[2]),
        4
    );
})

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

Not the solution I was hoping for here, but I’ll accept that. I think that’s the best I can do here.

1 Like