GameSalad

Trouble with camera resize and angle calculations

AdrenalineAdrenaline Posts: 500Member, BASIC

Hi everyone! It's been a while—I took a break but I'm coming back now to (hopefully) finish a game I put on hold. And I just ran into an issue I'm struggling to resolve. So let's dive in!

In my game, I'm calculating angles to rotate an actor based on the user's touch position. I've implemented this behavior by way of help from all of you over the past few months (thank you!). I'm also using an unlocked actor to control camera adjustments so I can account for different devices (also found via these forums!).

My game project is built for iPad Portrait. Everything works great when testing at this size. But when I change the device to anything else and set it to Stretch, the camera rules in the unlocked actor become active. Visually, this works perfectly! For example, a circle is resized to remain a perfect circle no matter what device size I'm using—good! However, SOMETHING is breaking—angles are not calculated correctly on device sizes other than iPad Portrait. This becomes evident when you touch to rotate the actor I mentioned above. Interestingly, the calculation is correct at angles of 0 and 180, but the errors gradually become more of a problem as you approach 90 (and 270).

I have no doubt that my descriptions above are confusing, so I've attached an example file. Just click and drag around the circle to rotate an actor. Change the device size and you'll notice the errors. Now, turn OFF all of the rules in the unlocked "cameraController" actor and the errors disappear.

Please help! And don't hesitate to follow up with questions so I can clarify my issue, if necessary.

Thanks in advance :smile:

Comments

  • pHghostpHghost London, UKPosts: 2,059Member

    Unfortunately, dynamically changing the camera size causes all sorts of problems with angles, mouse.position, collision (touch) etc.

  • Two.ETwo.E Posts: 357Member, PRO

    I would suggest using OverScan, and just changing the camera size to either "zoom out" or "in" depending on the game. You won't have to re-size every actor, and calculations will stay the same.

  • AdrenalineAdrenaline Posts: 500Member, BASIC

    Thanks @pHghost and @Two.E

    On a related note: if I decide to go with Overscan and then try to preview the game on my iPhone via the GS Viewer app, it's showing as if I chose Stretch. I don't see anywhere to change this. Is it a shortcoming of the app, or am I missing something?

    Thanks!

  • BBEnkBBEnk Posts: 1,718Member

    The problem is your playing with changing the origin of the camera that's causing your issue use the offset to move objects up to account for new device size. also, you should not put your camera logic on the game scene. use an intro scene it only needs to run once, and then you only need a change camera size on each scene thereafter. you can see changes I made to your template hope that helps.

  • AdrenalineAdrenaline Posts: 500Member, BASIC

    Thanks @BBEnk ! I'll take a look tonight. I appreciate the help.

  • AdrenalineAdrenaline Posts: 500Member, BASIC

    I've got it working to my satisfaction now, but it requires Overscan. When I preview the game via GS Viewer on iOS, it's not using Overscan. Is this just how the Viewer behaves, or am I doing something incorrectly?

    Of course, I plan on testing it in more robust ways later. But Viewer is convenient for now.

  • Two.ETwo.E Posts: 357Member, PRO
    edited November 6

    There is an option to change the setting in the viewer. The three options are:
    OverScan
    LetterBox
    Stretch

    It normally in the top left corner.
    Best,

  • AdrenalineAdrenaline Posts: 500Member, BASIC

    In the GS Viewer app on iOS?

  • Two.ETwo.E Posts: 357Member, PRO
  • AdrenalineAdrenaline Posts: 500Member, BASIC

    Found it! Top left corner. I can't believe I've used this Viewer so many times and never noticed that setting available. Wow...

Sign In or Register to comment.