Is better multi touch rotation possible?

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited November -1 in Working with GS (Mac)
After some good honest feedback I'm trying to improve 'Quake Builder'.

The 3 main things that have come back are:

- Not enough levels (this I can sort out)
- Unlocking the birds is annoying (this I can sort out)
 - The multi-touch on the blocks don't rotate very nicely.

At the moment, you can click these blocks with one finger and they will move to touch. They will then rotate to the angle of a second touch.

Ideally it would work so that:

 One touch it would move to touch.
 Multi touch. It would move to where the two fingers are, and match the angle between the two fingers, not just rotate round to the angle of the second finger. It's obviously hard to explain this by text.

Below is what I want. (but without the scaling effect)



at 2 minutes 45 seconds you can see how the blocks currently rotate.

Comments

  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    constrain: self.position x to floor(touch1.position.x/2)+floor(touch2.position.x/2)
    AND
    self.position y to floor(touch1.position.y/2)+floor(touch2.position.y/2)

    Is used floor to keep the actor on a whole pixel as opposed to half pixels...not sure if that is important though.
  • IgnisIgnis Member Posts: 72
    First of all, great-looking game, nice concept!

    As for the multi-touch rotating objects, I have been wrestling with a similar issue in my own game concept. With drag+rotate objects, my own dilemma is how "awkward" it can be when the user has one touch on the object, and his/her hand/elbow can get twisted in a fairly uncomfortable manner if they try to rotate too far. To explain this better, try putting two fingers on any surface (your index and middle finger). Now try rotating your entire hand counter-clockwise while keeping your first finger in the same place. 90 degrees is fine, but get up toward 180 degrees of physical rotation and the elbow bends in a rather uncomfortable way! At least it does for me... some double-jointed people might have better luck. :)

    Anyway, I was pondering one option which might work. I have achieved maybe 50% functionality on it, and somebody with more GS programming skill could easily accomplish it. The concept is a "touch-lock" kind of system. In the case of QuakeBuilder, the user would touch or double-click/touch a block, and that block would become selected and locked to itself to further manipulation, without using multi-touch. For example, imagine a longer rectangle object as shown in your video. The user would first "select" it. Then, using one finger, the user could rotate this object. How? With an imaginary vector line drawn from the object's center to the mouse/touch location. The object would basically rotate in coherence with that vector line: if the user touched somewhere to the right of the object, and dragged downward, the object would rotate clockwise. If the user touched to the left of the object, and dragged downward, the object would rotate counter-clockwise.

    Furthermore, the touch-lock system would prevent other objects from being manipulated at the same time. If one object was selected (locked), that object would be the only active object, and no other objects would be affected by user input. A single or double-click/touch action on that object might de-select it, so the user could regain control of other objects in the scene.

    My own problem in completing this behavior is the math... I haven't yet determined how to rotate the object as if the imaginary vector line was linking the object's center point to the user's touch point, all while constraining that rotation as the user drags the touch point around the screen. Any experienced GSers, I would be very appreciative for some tips/ideas on this!

    So, that's my suggestion for your QuakeBuilder rotation. It might not be practical with the time limit constraint... perhaps too clumsy to be constantly selecting and de-selecting objects while the timer runs down?
  • EastboundEastbound Member, BASIC Posts: 1,074
    "You little pesky rodent. Well, not a rodent"

    This made me chuckle
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    I just wrote a reply but it failed to appear.. grr...

    @bark - will try thankyou... (What does floor do?) will consult wiki.

    @Ignis - cool idea, would look nice if everything else in the scene dimmed so only the selected object was lit up.. anybody want to finish off the coding theory.

    @eastbound - glad to be of service :-)
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    just trying barks method now...uploading adhoc version, in the mean time lets get on with Lost Episode 14....its getting so good and it's so nearly over...
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Floor chops off the info after the decimal, leaving you with a whole number.

    Keep in mind that that solution did not address the rotation side of things, it just gets the actor to stay in the center of the two touches.

    I figured you could mess around with the options to keep the actor at an angle relative to the two touches.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    Ok,

    so have tried adding what Barkbark suggested:
    barkbark00 said:
    constrain: self.position x to floor(touch1.position.x/2)+floor(touch2.position.x/2)
    AND
    self.position y to floor(touch1.position.y/2)+floor(touch2.position.y/2)

    It sort of works, some teething problems, still not spot on.

    a) 1 touch, block moves to where touch is,
    b) 2nd touch, block moves to position in between two touches, and rotates (albeit in a stupid way to the correct angle).
    c) Problem, when you let go the block snaps back to the position of the 1.touch position. Which does not look right a bit jumpy, ideally it would keep the offset.

    hmm....will have to have a think on how to get it just right....certainly heading in the right direction.

    anyone else care to chip in?
    at the moment I'm still using Rotate to positon to get the correct angle.
    postion x = touchs 2.x to game touchs 2.y offset angle = 0
    speed 150

    @Bark, just seen your other post...cheers..
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Couldn't you just require both touches for any movement to take place? Add a rule for the value of touch2.position.x to be greater than 0.

    I can't test the multi-touch on any iDevices yet, but I will play with this when I get home. I almost think a single touch solution would be better UX-wise anyways.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    yeah i guess making it only moveable with 2 touches would work, might confuse the user at first.

    the one touch only option would work nicely, but i like to think multi-touch adds a little something special to the game, and device.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Ok, so what exactly would you like it to do at each level of interaction (1 touch, 2 touch, 1 or more touches released..etc)?

    Whatever it is, I think it is possible. ;-)
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    I'm not sure if the perfect multi touch is possible, means changing the rotation point.

    Ok I guess the multi-touch dream would be:

    1st touch: - To move the block around. (but also 'not' snapping the centre of the block to the touch position, keeping an offset of where the block is touched, it's already set up to this way for all blocks, so you can touch on the edge of a block and move it and it wont jump its centre awkwardly)

    2nd touch: - Should allow for rotation, rotating around the first finger position (not the centre of the object), Not rotating to the angle between the two fingers, but instead once the second finger is pressed, if it is then dragged clockwise, the block rotates clockwise, and vice versa.

    when 2nd touch is released, go back to just moving with 1 touch.

    and if the 1st touch is released instead of the 2nd, have the block maintain its positon and become moveable form where the 2nd touch is. (This would stop any awkward jumping when a user lets go of both fingers, and one stays on more than the other).

    Think that makes sense....possible....?
  • IgnisIgnis Member Posts: 72
    StormyStudio,

    Below is the link to a very rough test template I tossed together. However, it might provide some ideas how you could implement your QuakeBuilder object movement using just one touch, not multi-touch.

    The idea here is, the user clicks/touches the object. That "locks" the movement to that object while the mouse button remains pressed, even if the pointer moves outside of the object's boundaries. This is what I meant by my previous post about a touch-lock. The user can then slide the object left and right (vertical free-form movement could be added with another similar rule). The object also rotates to the mouse location, and moving the pointer outside the object's dimensions allows for fine-tuned rotation.

    As I said, this is a very rough template which needs considerable modification. The aspect I dislike the most is that the object rotates with alot of sensitivity when the mouse/touch is near the object's (0,0) center. Ideally, I would like to implement "hot points" on the object: specifically, the object would rotate only when the mouse pointer was located near the tip(s) of the bar. This could probably be accomplished by measuring the distance of the mouse pointer from the object's center, using a sine or cosine formula depending on the object's rotation angle, and determining if the mouse pointer is located near the tips.

    As for movement of the object (sliding/dragging around), that would occur only when the mouse pointer was located closer to center, away from the tips.

    Anyway, check it out and let me know if this helps; or, please suggest improvements to this basic concept since I want to use a similar behavior in a future game.

    http://gamesalad.com/game/play/56546

    Note: one existing "bug" is that both objects in this scene can be selected at the same time, if you manage to run your pointer over both while keeping the button pressed. This would be easily remedied by creating a boolean Game Attribute called "select-lock". When any object was selected, select-lock would be set to "true". When the object became de-selected, select-lock would be set back to "false". A rule within the actor prototype would prevent an object from being selected if select-lock was already true (in effect, only one object would be selectable at any given time).
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    @Ignis,

    You can use magnitude to calculate the distance between the touch position and actor position (when the actor is touched) to check to see if it is near the center. If it is close to the edge, just check to see it the touch's x position is greater than or less than that of the actor; if greater, moving the touch up would rotate cw, down would rotate the actor ccw...and vice versa. No complex math needed... ;-)
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    The suggestion from my last post wasn't as easy as I thought it would be...

    Here is a demo: http://gamesalad.com/game/play/56582
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    I found 2 bugs with the above demo...

    #1 Turn a block greater than 90 degrees. De-select. Try to turn again. The block starts rotating in the opposite direction...
    #2 Slowly rotate a block back and forth across the 360-0 degree threshold. The block starts quickly rotating in the wrong direction.

    If anyone can look at the logic and tell me/us what is wrong, that would be awesome!
  • Rob2Rob2 Member Posts: 2,402
    Works great online (except for the small bugs) but it's twisting my swede trying to get it deviced up! (I expect it is very obvious!!)
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @Barkbark...

    that demo works really well...apart from the couple of bugs mentioned...

    you've 90% convinced me this is the way to go.

    thanks for making and posting the demo...Much appreciated.
  • Rob2Rob2 Member Posts: 2,402
    @stormystudio does it work on your phone?
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    not tried it yet, will have a go at updating the blocks in my game and see how that goes...

    I guess it will need to work perfectly before I fully update the game.

    Can't see why it would not work on a phone though.
  • Rob2Rob2 Member Posts: 2,402
    at the moment touch is locked out by the logic and it's doing my nut in....

    edit.... actually I don't know whats going on ..it just doesny work on ma phone
  • Rob2Rob2 Member Posts: 2,402
    @barkbark no solutions?
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    I can't test on the iP(ad|hone|od) yet ... so, no.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    @stormy, Any luck?
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    not tried yet... just updating my website, and putting a GameSalad London meet involving beer as actors on youtube....

    will have a look in a bit...
  • rebumprebump Member Posts: 1,058
    @stormy - I'm not on a Mac to look at Bark's solution but from the sound of your solution's issue regarding the second touch and the actor's rotation snapping back to some position upon second touch release...sounds like upon second touch, you need to store either the 2nd touch's X/Y position in a game attribute pair or the computed rotation of the actor in a game attribute and constrain the actor's rotation to one of those two methods using the game atttribute(s) you set up.

    As you describe your issue, it sounds like upon 2nd touch, you are constraining rotation to the vectorToAngle() value of the actual touch coordinates (and not them stored in a game attribute pair) and upon 2nd touch release, those go to "0" or something causing the snap back.

    You may want to clear the aforementioned game attribute(s) after their usage so the next 2nd touch doesn't cause a quick "lurch" rotation upon first contact of the 2nd touch.

    Edit: Re-orged the content a bit to clarify.
  • Rob2Rob2 Member Posts: 2,402
    Has anyone got this project working on an idevice, and if so what did you change?
  • Rob2Rob2 Member Posts: 2,402
    bump
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    will have a proper go at this tonight.

    Need to get my multi-touch blocks working better.

    Lots of discussion on the subject here:
    http://gamesalad.com/forums/topic.php?id=4558

    Amazing how well the forum search works if you use Google instead.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    barkbark, seen you've improved the project... how did you do it?

    the project is not available for download.

    Looks like it works 100% perfectly.

    ?? :-) ??
Sign In or Register to comment.