Getting touch offset to play nicely with thrown object.

GraybayGraybay Member Posts: 114
edited December 2011 in Working with GS (Mac)
So basically, I have created a scene with touch offset and a larger hitbox, COMBINED with throwing an object. Once touch offset is added to the equation, throwing won't work anymore. As you can see in the included scene file, the farther you touch from the object, the farther the object flies.

Weird behavior, I've been going at this all morning and getting nowhere. Any ideas would be very welcomed.

http://www.mediafire.com/?85gnnfe85ls4bg1

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    The method you are using needs to be slightly modified in order to work with offsets. Here is the quickest way to fix what you already have.

    First make two new 'real' attributes: oldMouseX and oldMouseY
    Next, modify the last two constrain behaviors like this:

    Constrain Attribute: self.Motion.LinearVelocity.X To: 10*( game.Mouse.Position.X - self.oldMouseX )
    Constrain Attribute: self.Motion.LinearVelocity.Y To: 10*( game.Mouse.Position.Y - self.oldMouseY )

    Then add two more constrains:

    Constrain Attribute: self.oldMouseX To: game.Mouse.Position.X
    Constrain Attribute: self.oldMouseY To: game.Mouse.Position.Y

    Make sure that the oldMouse constrain behaviors come after the linear velocity constrain behaviors (as above), order is important.

    Lastly, you probably need to use a larger multiplier than 10. (But that is a personal preference.)

    Hope this helps!
    RThurman
  • GraybayGraybay Member Posts: 114
    Thank you RThurman for looking at this for me. Your method worked great within the creator preview, however this solution doesn't work at all once running in the GSviewer. The block doesn't inherit any motion from the finger swipe, is there a finger touch attribute that can be changed instead of mouse? I must be missing something important. I included my updated scene which works well in the creator but not on the device.

    http://www.mediafire.com/?92nwwpnavzg6eg5

    Thanks again!
  • GraybayGraybay Member Posts: 114
    Is it common for actors to behave differently on the viewer than they do in the creator?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @Graybaysaid:
    The block doesn't inherit any motion from the finger swipe, is there a finger touch attribute that can be changed instead of mouse?
    Yes, if you change all the references of 'game.mouse.Position.X' to 'game.Touches.Touch 1.X' your game will work on the Viewer. (The same goes for the 'Y' references.)

    Hope this helps!
    RThurman
  • GraybayGraybay Member Posts: 114
    Thanks RThurman, all is well now!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    You are welcome! Glad it works for you.
    RThurman
Sign In or Register to comment.