phone on side, landscape mode, Beta/Gamma, C3, Brain pain.

  • I may need a video walk through for this one, I'm confusing myself.

    Using C3.

    I made a game where a ball goes through a maze. The ball is moved by tipping the phone around, using Beta & Gamma. It worked great, so I understand the basics of 'compare orientation'.

    That game laid flat except for the tilting - Now I’m making a new game where the phone sits landscape on one side - and I’m completely lost.

    I admit I guessed A LOT when making the ball tilt/maze game, but that’s how you learn, right?

    I can’t seem to guess my way through this one.

    The new game is pretty simple. You stand up with the phone in front of you. There is a stationary dot in the middle. You move the phone up, down, right, left, 360 to scan the playing area (3840 x 2160).

    You put the stationary dot on the objects to collect them. The objects are stationary also.

    (At the moment I’m calling the game ‘Motion Sick’)

    It works great as long as it is laying flat and just tilted like the ball maze/tilt game, but if I put the phone on it’s side - up becomes down and moving right can be up or left - it’s crazy. It doesn't seem to matter what I put in Beta/Gamma.

    Please, how do I set that up? Do I still use on touch? Or do I use grid?

    I promise I have searched for the answer and it may be that I’ve just read so much that I’m confusing all the information.

    Clues? Thoughts? (maybe a decent joke to get me through?)

    Thanks in advance.

  • The one word solution for you can possibly be: "Calibration".

    The ball maze game works perfectly because beta/gamma orientations (Gyro sensors) are calibrated at 0,0,0. When you tilt, they change. When you hold it landscape, it obviously have a big value in either alpha/beta/gamma (most likely alpha?).

    First thing: You must display the round(alpha), round(beta), etc. values on screen throughout to be able to visualize what's happening when you tilt. I hope you're doing it already? If not, I can't believe you.

    To make things static when phone is held landscape (i.e. to have 0,0,0 at that position/orientation), you need to subtract that amount of tilt you've done. That's called calibration.

    For that, you need three orientation variables (instead of using alpha, beta, gamma directly). Lets say you call one of them alpha_var, which is initially 0. Now, Every tick: alpha_var set to alpha_var + Touch.Alpha. And before starting the actual game, you must show a button "Calibrate". Once clicked, it should subtract all orientation values from those variables to make them all zero. And then use those variables as orientations (just like your maze game) because now, they become 0, 0, 0, on landscape (after calibration), just like previously 0, 0, 0 was on laying flat.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • First, thank you for that detailed explanation. I feel like the fog is beginning to clear a bit. Thank you.

    I'm using A/B/G on the screen, but it's not helping much. Alpha jumps from 160 to 347 with the slightest tip.

    (I'm using this one: iticka.com/purchased/11/index.html )

    I am going to read through this again and them attempt.

    Thank you.

    I'll keep you posted.

  • Now I'm more confused.

    In landscape - Gamma is up and down. Alpha seems to be spinning around in a circle. Beta seems to be tipping the left or right side of the phone up or down.

    So I need to worry about Gamma and Alpha, I don't think Beta will matter much, right?

    youtube.com/watch

  • Of course you're confused, your avatar pic says it all.

    But, what seems to be wrong? The video preview shows correct changes in readings and you tested them all well. And it worked well, didn't it?

    So now you know what each of them say, how to reset them (in the beginning if you have to), and it can detect where the phone is tilting exactly.

    Except, two problems: the Beta -179 goes to plus 180, suddenly which can cause problems if you're performing actions relative to Beta values... The sudden jump. But it can easily be resolved by some math. Search on this forum you'll find many similar problems and solutions.

    Second, if you're worried about the sudden wrong readings due to spikes and jerks, you can easily eliminate that by 'easing' out the values. i.e. Instead of showing "exactly" what it the sensor reads, let it gradually go towards the value, which helps in filtering wrong values in between (i.e. jerks).

    You can do that by using the 'lerp' function... Look it up.

    Example: alpha_value = lerp(alpha_value, Touch.alpha, 0.4)

  • LERP - Dude! Just watch a tutorial on lerp. Not exactly sure how it's going to fit in, need to research more, but I think it could be the answer to my problems.

    Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)