How can I get Position coordiantes of 3D object on bezier


#1

Hi.
With animation/timeline I am movin 3D object on bezier.

Problem - I couldn’t get it working:
I need to access coordinates of animated 3D object ON THE END OF BEZIER.

Once more: I have bezier, timeline and simple 3D object positioned on start of bezier, then I move/animate it on bezier.
In code (timeline’s controller “on complete” event), I need to access this 3D object position coordiantes, because I am creating instance of 3d object, and I ned to set its position to those coordiantes.

I was checking zappar docs about, Subsymbol Communication, but didn’t help.

Thanks


#2

Hi @interactive,

Thanks for your question.

You can get the position of a node using the position() getter function.

This will return the current position of the node, in the following form:

[x, y, z]

Default value:

[0, 0, 0]

You can then use the position() setter function, to set an objects position.

Example:

myobject.position([1, 0, 0]);

Hope this helps! :slight_smile:
George


#3

Thanks for answer.

I tried also this, but the problem is that .position() on bezier animation has always the same values. They are not changing.
I am trying to read those coordinates on the end of my “timeline animation”, but values of the node (values in .position()) are same as start position, even though the object is on different location at that time - on the end of bezier.

This is timeline event I am using for reading position coordinates and doesnt return end position:
Capture1

On this image you can see my hirearchy. One simple 3D ball Zoga.obj on bezier:
image


#4

Hi @interactive,

My apologies!

You are correct, a 3D model will always return 0,0,0 when it is animating along a bezier curve.

To overcome this, you can add an invisible plane relative to the 3D model and get the plane’s position instead.

I’ve added a quick image to help explain this below.

Please bear in mind that this is using the bezier example project and subsymbol.

The same position() getter function will work, much as explained above.

Hope this helps.

George