I am trying to create parabola logic for Spark AR studio using only javascript (without patches)
there is a limitation to my project
Okay, I have 1 parent object with 1 child.
Ball for control rotation and positionFussball.001 only adds position z vector to make the ball in front of the player's footMy goal is I want to kick the ball to the target based on the rotation of Ball, for example, the ball position is 0,0,0, and ball rotation is 0,45,0, so the ball target is -0.51721, 0, -0.51721 it's just example, here's simulation if I do it in spark ar viewport
I know I can create easily with getting object global transform, but the problem is global transform is sucks if I use inside plane tracker. for now my script only like this, just get the vector position and rotation only and send it to patches
var target_position = null;
target_position = [0, 0, 0];
const [x, y, z, rotationY] = await Promise.all([
Patches.outputs.getScalar("x"),
Patches.outputs.getScalar("y"),
Patches.outputs.getScalar("z"),
Patches.outputs.getScalar("rotationY"),
]);
x.monitor().subscribe(() => {
target_position[0] = x.pinLastValue();
});
y.monitor().subscribe(() => {
target_position[1] = y.pinLastValue();
});
z.monitor().subscribe(() => {
target_position[2] = z.pinLastValue();
Time.setTimeout(() => {
Patches.inputs.setVector(
"ball_shooting_target_position_sender",
Reactive.vector(
target_position[0],
target_position[1],
target_position[2]
)
);
}, 50);
});
rotationY.monitor().subscribe(() => {
Diagnostics.log(rotationY.pinLastValue());
});
I think this case is similar with web-based javascript game, but i don't know the correct keyword to search it through google. Thanks