How do I make a Accelerometer Canon?

dondan89dondan89 Member Posts: 150
edited November -1 in Working with GS (Mac)
Hello

How do I make a Accelerometer Canon? But specific place on top of the scene on for portrait iphone.

thank you

Comments

  • SkyMapleSkyMaple Member Posts: 817
    Can you please explain?
  • dondan89dondan89 Member Posts: 150
    You see that canon move by moving the mouse? I want the same movements as canon, but to control it using Accelerometer movements
  • dondan89dondan89 Member Posts: 150
    but I do not know exactly where to put the accelemeter
  • keweworkshopkeweworkshop Member Posts: 377
    Sorry dondan for RKS' remark, I have never played with the accelemeter so I can't help you, guess I'm dumb too. My suggestion would be to search on youtube or in the cookbook and find videos and help there.
  • dondan89dondan89 Member Posts: 150
    Thanks you
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    I think RKS was trying to make a joke:

    How do you make an accelerometer cannon . . .
    Fill it with accelerometers!

    EDIT:
    By the way, if you want to get "down" (meaning the angle the accelerometers say points to the center of the earth), it would be
    (vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )+90)%360

    The '90' is to compensate for the device being in landscape orientation. If you want it in portrait mode, just take the 90 out.

    Hope that helps!
  • keweworkshopkeweworkshop Member Posts: 377
    RThurman said:
    I think RKS was trying to make a joke:

    How do you make an accelerometer cannon . . .
    Fill it with accelerometers!

    Oh your are probably right. I thought that was extremely out of character for him.

    Sorry RKS, your joke went over my head!
  • dondan89dondan89 Member Posts: 150
    Can you give me a small template?

    I got a black screen with this
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Try this...

    Make a cannon actor. The actor's image should point exactly to the right.

    Place the following behavior in the cannon actor:
    Constrain Attribute: self.Rotation To: 90 + (vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )+90)%360

    Be sure to use the drop-down menu in the expression editor to get 'self.Rotation', 'vectorToAngle', 'game.Accelerometer.X', and 'game.Accelerometer.Y'. Don't just type them into the expression editor.

    Hope that helps!
  • dondan89dondan89 Member Posts: 150
    do I have to use angle rotation or just constrain attribute?

    did not work, does also have to do with image?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Use the Constrain Attribute behavior.

    The image does not matter. (Try it with a blank actor. But make it 'face' to the right. Just as it is when it is dragged onto the scene.)

    I'll need more feedback than "did not work." Can you describe what is not working?
  • dondan89dondan89 Member Posts: 150
    Is not moving like a canon, it be more easy if you make me small template

    so i can see exactly what to do

    thanks
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Its not moving like a cannon -- but it is moving? Is it rotating around its center? Is it rotating consistently. Is it staying horizontal as you move the iPhone around?

    Hmmm.... are you testing it on a IOS device?
  • dondan89dondan89 Member Posts: 150
    yes, i did test it on device, and did not move at all,
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    OK -- here is a little demo. Its tested and works.

    http://speedy.sh/4xnQh/LevelFinder.zip
  • dondan89dondan89 Member Posts: 150
    Thank you so much for the demo, it had help me a lot
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Glad it works!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @RKS -- I thought the joke was funny! (But I have a dry sense of humor.) It helped a lot!

    I'll tell you what. You can help dondan89 if s/he wants to know what to do when the cannon angle passes through the "360 to 0" border and starts firing the shots in the wrong direction.
  • sessiensessien Member Posts: 41
    @RThurman, do you mind sharing the demo. I am looking for a way to do the say thing. Regards./
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
  • sessiensessien Member Posts: 41
    Thanks for sharing.
  • sessiensessien Member Posts: 41
    Here is a file of what i am trying. The speed works yet when tilted it slows down

    http://www.speedyshare.com/file/WzPQf/rockkk.gameproj
Sign In or Register to comment.