Help with accelerometer controls. Transition is choppy.

ChakkuChakku Member Posts: 1,513
Hey guys,

I'm making a game where im controlling a flying vehicle with accelerometer controls. So I have it so that when attribute.rightis on is true, change attribute.leftison to false then accelerate right at speed 150. Then if attribute.leftison is true, then turn attribute.rightison to false and accelerate left at speed 150.

But the transition is not smooth. The vehicle slows down for a second (because the 150 going left is fighting with the 150 going right) then it flys in the opposite direction. I need it to be very sensitive for my game.

Its probably a very similarly easy question to the one @Braydon_SFX @jamie_c @SlickZero answered, although it sounds complicsted.


All help is appreciated.

Thanks

Best Answers

  • RThurmanRThurman Posts: 2,881
    edited December 2012 Accepted Answer
    @Chakku

    I don't think anyone wants to help you now because you are rejecting those who answer. This is definitely _not_ nice. I suggest you go back and accept the answers you were given.

    I assume you think that accepting an answer means that the issue is closed and that you don't want more help. This is not the case. Accepting does not mean that you don't want more help. It actually means you are thanking them and accepting what help they have offered.

    ----
    Now, on to an answer that I hope is _not_ rejected.
    It seems you have two issues that you are trying to solve. First, you are concerned that the tilt controls are too sensitive. Second, you want the object to have some residual momentum before it begins going the other way. (You want it to smoothly slow down, and then reverse direction.) Lets work on the second issue (and maybe the first issue will go away).


    Make a new actor and test to see if this is the kind of acceleration/deceleration you want:

    Rule:
    When key (right arrow key) is down:
    -- Accelerate
    ---- Direction 0
    ---- Relative to scene
    ---- Acceleration 150

    Rule:
    When key (left arrow key) is down:
    -- Accelerate
    ---- Direction 180
    ---- Relative to scene
    ---- Acceleration 150


    Test this out (using the arrow keys) and confirm that it has the slowing and reversing you want. If yes, we can work on tilt controls.
  • RThurmanRThurman Posts: 2,881
    edited December 2012 Accepted Answer
    Glad you feel you are getting there. How about trying this on the actor:

    Go to the actor attributes (on the left) and under the motion attributes, set "Max Speed" to 200. Check the "Apply Max Speed" box.

    Then modify the behaviors from the previous test.

    Rule:
    When key (right arrow key) is down:
    -- Accelerate
    ---- Direction 0
    ---- Relative to scene
    ---- Acceleration 1000

    Rule:
    When key (left arrow key) is down:
    -- Accelerate
    ---- Direction 180
    ---- Relative to scene
    ---- Acceleration 1000


    This will have the effect of making the acceleration ramp up very fast, but it will never go faster than 200. (It will speed up the transition time -- but not too fast).

    --------------------------
    Finally, when you have it working like you want, transfer this back to your original actor. Use this with your "attribute.rightison" and "attribute.leftison" rules (instead of the keydown rules).

Answers

  • ChakkuChakku Member Posts: 1,513
    does it sound very complicated?

    In simpler worlds, I want to control a rocket with tilt thats flying and i want it to sensitively move right or left using the accelerometer.

    so basically sensitive tilt-based controls.

    I've tried all the tutorials, but i seem to be doing something wrong.

    Now this is probably very easy to the GS Pros out there, so can anybody help?
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Did you see this youtube video yet?...

    Instead of using "Accelerate", you would use "Rotate" and play around with the rotation speed to get the desired effect. I've used this method in a lander type game I had a couple of years ago, and it worked great.
  • ChakkuChakku Member Posts: 1,513
    @SlickZero

    yes, I watched that video. I'm not saying it doesent work. But when im tilting right, then i change to tilt left, it slows down for a second..then flies left! There is no balance and it looks weird.

    My game needs precision sensitive tilt controls.

    Are sensitive tilt controls possible in GameSalad?

    Thanks for the reply.
  • ericzingelerericzingeler Member Posts: 334
    Is this a side scroller type game?
  • ChakkuChakku Member Posts: 1,513
    edited December 2012
    @eezing NO, its a flying game where u tilt to control the flying plane. its an arcade game, and it requires a sensitive accelerometer.

    Thanks for the reply.
  • ericzingelerericzingeler Member Posts: 334
    First you have to filter the accelerometer input to make it more smooth:

    3 Attributes (Real):

    1. accelX (new filtered accelerometer X output)
    2. accelY (new filtered accelerometer Y output)
    3. kFilteringFactor (smoothness amount... a number between .01 and .09 usually)


    Constrain accelX = (acceleration.x * kFilteringFactor) + (accelX * (1.0 - kFilteringFactor))

    Constrain accelY = (acceleration.y * kFilteringFactor) + (accelY * (1.0 - kFilteringFactor))

    Second, convert your accelerometer output to movement:

    Example:

    Move left and right on X-Axis

    1 Attributes (Real):

    1. speedAmt (most likely 25 to 300)

    Move Behavior:

    Direction = 0
    Relative to Scene
    Move type = additive
    Speed = ((accelX * 10) * speedAmt)

    Note you may have to change 10 to -10 in the Speed equation to reverse direction of actor
  • ChakkuChakku Member Posts: 1,513
    edited December 2012
    @eezing Thanks. I'm kinda new to GameSalad, and am not familiar with Real attributes. I will try it, and update you if it works.

    Thanks for the reply.
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    @chakku
    Did it work, Because this is most deffinately an issue with real attributes?
  • ChakkuChakku Member Posts: 1,513
    @eezing can you simplify that a bit for me?

    How do i get the acceleration.y attribute?

    Thanks a lot for your help
  • gamesfuagamesfua Member Posts: 723
    Hey @eezing that was impressive coding you just did there. I hate to piggyback on this question- but here i am :)
    I too am making an accelerometer game. I followed the video tutorial and have had moderate success with simply using the x axis accelerometer controls linked to an acceleration behavior. I, like the video, simply did something like IF character is greater than a certain x coordinate than move left (or right- depending obviously on the coordinate). The sensitivity was set to .01 like the video. But you seem to be talking about some kind of filtering or smoothening. Can you explain that? I'm sure it'll help with the original question as well. Your example seems to be far more complex, but ultimately far superior for sensitivity and accuracy. Any help would be phenomenal. Thank you!
  • ChakkuChakku Member Posts: 1,513
    Any help?
  • ChakkuChakku Member Posts: 1,513
    @RThurman Thanks for clearing up my misconception. Your assumption was correct; I did think accepting meant my issue was resolved! Thanks again.

    I will try out your arrow key suggestion next time I get to my Mac.

    Oh, and very important FYI, my tilt controls ARE NOT very sensitive and I want them TO BE sensitive. But you are correct of my 2nd problem of needing a smooth transition between changing directions.

    Thanks for your reply.
    Chakku
  • ChakkuChakku Member Posts: 1,513
    edited December 2012
    @RThurman Yep, the keyboard worked, it's just like I want the tilt to be, except when it changes direction from left to right (or vise versa) there is a transition time, I want very minimal smooth transition time so it turns easily.

    Converting to tilt is what's not working for me.

    Really appreciate your help.

    Thanks,
    Chakku
Sign In or Register to comment.