playMaker

Author Topic: Push-button rotate camera around object at 90 degree intervals [Solved]  (Read 1712 times)

JoeGameDev

  • Playmaker Newbie
  • *
  • Posts: 21
I have a 3D object, a cube, in the middle of my screen. I need to be able to press a button and make the camera orbit this object in increments of 90 degrees in either direction. Press left, camera swings left 90 degrees. Press it three more times and you’re back where you started.

I’ve managed to make the object itself spin in this manner, using Tween Rotation (World Rotation option), but it turns out my project is better suited if the camera itself moves, but I have no idea how to do this. Any ideas?
« Last Edit: January 13, 2024, 05:26:35 PM by JoeGameDev »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Push-button rotate camera around object at 90 degree intervals
« Reply #1 on: January 12, 2024, 10:07:18 AM »
parent the camera to a empty object, centered to the cube.
then rotate that empty game object.

JoeGameDev

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Push-button rotate camera around object at 90 degree intervals
« Reply #2 on: January 12, 2024, 10:26:39 AM »
parent the camera to a empty object, centered to the cube.
then rotate that empty game object.

Brilliant! Thanks man I’m gonna try that today and update later!

JoeGameDev

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Push-button rotate camera around object at 90 degree intervals
« Reply #3 on: January 12, 2024, 01:19:37 PM »
Update: Okay, thanks to djaydino’s help, I can now rotate the camera around the object. But now I have a new problem.

I was using Tween Rotation, with World Rotation as the option, 90 on the Y axis. What I’ve discovered is that this just snaps the camera to that Y axis coordinate. So what I need to be able do is add 90 to the rotation with each press. Offset World Position seems to be the answer, right? Well, for whatever reason, it doesn’t actually offset the camera by 90. It’s a little more or less than that each time. So what ends up happening is that after a several presses, the object is no longer square to the camera. Is there a way to ensure the offset is always 90? I see there is an option to use a variable but I wouldn’t know what to actually do.

Help!

Edit: I think I figured it out. The problem seems to be, that I could click faster than the cube rotates, so I would interrupt the rotation with another offset of 90°, which threw the whole thing on whack.  I decreased the ease time on the tween to .1 seconds which seems to be faster than I can click, and the problem seems to be solved. Thanks again.
« Last Edit: January 12, 2024, 03:44:04 PM by JoeGameDev »