Change lenth of arrow created, dynamically

good day I create an arrow with:

const createArrow=(scene) =>{
const thickness=10;
var arrow = new TransformNode(“arrow”, scene);
var cylinder = CylinderBuilder.CreateCylinder(“cylinder”, { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (thickness - 1) / 4), tessellation: 96 }, scene);
var line = CylinderBuilder.CreateCylinder(“cylinder”, { diameterTop: 0.005 * thickness, height: 0.275, diameterBottom: 0.005 * thickness, tessellation: 96 }, scene);

const arrowMat = new StandardMaterial(‘arrowMat’, scene);
arrowMat.emissiveColor = Color3.Yellow();

cylinder.parent = arrow;
cylinder.material = arrowMat;
cylinder.rotation.x = Math.PI / 2;
cylinder.position.z += 0.3;

line.parent = arrow;
line.material = arrowMat;
line.position.z += 0.275 / 2;
line.rotation.x = Math.PI / 2;

return arrow;
}

So say that I create one of those arrows and I position it somewhere with some rotation:
myArrow=createArrow(scene);
myArrow.scaling = new Vector3(35, 35, 35);
myArrow.position = new Vector3(0, 60, 0);
myArrow.rotation = new Vector3(0, 0, 0);

And now, dynamically,and often, many times per second, depending on some other extra information and the specific point where the arrow is, I need to change the length of that arrow.
How can I change the length of the arrow, preserving its look, dynamically, once its been created?
I dont think that changing the individual scaling of one of the axis is the way, tried it without luck,
thank you for any help :slight_smile:

changing myArrow.scaling finally seems to work I think that could be the solution

1 Like