How to code an object rotate about its own axis?

How to code an object rotate about its own axis?
The rotational axis by default is outside the object. Can the axis be shifted?

1 Like

Hi @ha_sir.
Please use the turn around origin block.
turn%20around%20origin

Origin (0,0,0) local shifts the rotation axis to the object center

Thanks for your reply.
I have tried this one but cannot produces the desired effect.
In the screenshot, I want the star to revolve about its own central axis, but does not work.21%20AM

1 Like

Here is the setting of the turn function.
54%20AM

1 Like

Here is what actually happens. The star revolve about an axis outside the itself. Can the rotational axis be set and aligned with the centre of the star? I have tried various values of x, y, z of origin, but still cannot figure out a way to do so.

1 Like

Hello, could you please share with us your scene?

1 Like

Thanks, here it is:

1 Like

Hello Ha_sir,

thank you for sharing your scene. We found some wrong behaviour of “turn” block and we will fix it as soon as possible.

1 Like

You have a professional team!

1 Like

I’m also interested in this question. I could only choose either turn the object clockwise or counter-clockwise. Did I do something wrong?

1 Like

Hi @mikhailo @Nikolay ,

Still no clue for this issue ? I am facing the same problem.

https://edu.cospaces.io/UJA-UBQ

Thank you.

1 Like

Hi @tajajtsidi

This is a fundamental issue with the placement of the origin in Items: the Origin is not in the center of the object - it is in the center of the local X & Y, but at the bottom of the object for Z.

This is a problem which the dev team have been notified about - you can see my test examples at CoSpaces Edu :: Test - XYZ Rotation direction

The workaround for this is to use another object as your origin, place it at the center of your Item, hide it, and use the Position of Item CoBlock as the Origin coordinates in the advanced turn block.

Hope that helps!

Geoff @ TechLeap

3 Likes

Thank you @techleapnz

I have found some of these weird interpretations. It is a hard stuff to workaround.
Could you please see this example where I tried your workaround solution, it seems giving the same result.
https://edu.cospaces.io/VAM-YKH

Thank you so much.

1 Like

You did everything right, just had to position the cuboid closer to center. I moved it there and the girl turns on the chair:

2 Likes

For this particular example, you can use the basic turn block, as it rotates around the Z axis by default; and as Nikolay said, what you’ve coded here works perfectly (as coded). If you expected a different result, let us know.

Geoff @ TechLeap

1 Like

Any update to this? I’m trying to rotate a block by its x-axis but it keeps rotating in a different manner which I don’t like. I am unable to make it turn without moving the block.

1 Like

Hi @Gwydian_Carlier,

You can use a helper object and the Advanced rotation CoBlock to set a new origin and rotation around it’s local axis. Remix this demo and have a look at the code and setup - note that the origin is still at the bottom of the helper object (which I would change to transparent once I was happy with how it looked):

Hope that helps!

Geoff @ TechLeap

1 Like