How to rotate a 3d object vertically around a position?

Is there a way to rotate around a position vertically instead of horizontally. I tried the orbit extension and it made the same horizontal circle

https://editor.gdevelop.io/?project=https://resources.gdevelop-app.com/examples/orbiting-objects/orbiting-objects.json

1 Like

Thats if you are using a 2d sprite, but i am trying to move a 3d object

I need it to move vertically around a z position

@AnnieLWatts , could you start a new thread on this? Your requirements are different to the original post.

1 Like

I tried to tween to an x and y position and then elevated and decended the z position. Still could only wing the object around in a horizontal direction and not vertical.

Then I tried to tween to a y position then to a z position.

How do I move this thread to a new one?

@AnnieLWatts, done :slight_smile:

Can you update the title if needed, and describe the problem you’re having?

1 Like

How do I make an 3d object follow a predifined vertical and circular path?

In 3D or along a 2D plane?

in a 3d plane, is works horizontally, but not vertically

I tried to add forces on an angle, still goes around in a circle horizontally.

I don’t understand what you mean by it working horizontally but not vertically; they’re 2D alignments.

With working horizontally, do you mean it rotate on the Z-X plane - so coming in and out of the screen and going left right? Or something else?

I would love it if I can get it to work on the Z-Y plane to make it orbit in a left-up-right-down and left around a position or object.

Right now it orbit in a front-right-back-left-front motion.

Have you rotated the 3D camera at any point? Or is the Z axis still perpendicular to the screen?


[edit] actually just thinking, that shouldn’t matter.

Is the screen snip in your first post all that you have to rotate the object, or is there more?

Yeah, I tried to move the camera, without success.

I tried to move the z position and y position, but the circle is boxy.

for the most recent snippet, I changed the global variable DegreesA set to 360 at the beginning of the scene. The duckrotating is a 3d box.

The snippet before, I used the orbit extension.

I have it going in a square on the YZ plane. Still not a circle.

This may be a solution:

  1. create 2 object variables on duckrotating (say named rotatePointZ and rotatePointY)
  2. the start of the scene, set these 2 variables to the Z & Y coordinates of the point round which you want the duck to rotate.
  3. set a scene timer at the start of the scene, say called RotateTimer
  4. set the z position of duckrotating to duckrotating.rotatePointZ + 200 * cos(ToRad(TimerElapsedTime("RotateTimer") * 360))
  5. set the Y position of duckrotating to duckrotating.rotatePointY + 200 * sin(ToRad(TimerElapsedTime("RotateTimer") * 360))

You might have to change the cos and sin parts round. To spin it faster, increase the 360 multiplier. And decrease the 360 value to slow down the spin.

I think this should do it, but it may need some tweaking as I haven’t tried it out.

Looks scarey, but I will try.

The pointer lock does not always work.