Without further context, shouldn’t these code snippets result in the exact same behavior?
let initPos = new pc.Vec3();
let test = this.object.getPosition();
initPos.x = test.x;
initPos.y = test.y;
initPos.z = test.z;
let initPos = this.object.getPosition();
If there is a discrepancy between these two snippets then I am probably unaware about how PlayCanvas handles variables here, but I would expect both of these to store the object’s current position in a variable which stays unaltered, even when the object’s position updates.
If I’m wrong disregard the following, otherwise this project might be interesting because I get different results depending on which of the snippets I use:
https://playcanvas.com/editor/scene/1634016
(Script moveCommand.cs, launch the project and press Play, observe the white cube - initPos will return a different value when using the latter piece of code, causing the cube to jump in position)