Follow my finger!

CuckooheadCuckoohead Member Posts: 16
edited November -1 in Working with GS (Mac)
Hello everyone! I'm working on a sort of rpg game for the iPhones and I'm having a bit of trouble getting my character to move correctly. What I'm trying to achieve is something as follows: I want the character to move to a spot where your touch was released—after you've pressed on the inside of the character and dragged your finger to a specific location.

I want it to go at a set pace, without accelerating.

Again; movement can only be initiated if the character is pressed from the inside and then released on the outside. Is this possible? I know there have been many posts asking similar questions (many of which I've read, and tried), but none of them seem to work the way I want them to. If someone could give me an answer on how to accomplish this it would be much appreciated!!!

Thanks in advance!

Comments

  • CuckooheadCuckoohead Member Posts: 16
    Anyone able to help?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    make a interger attribute call it moveon or whatever

    in the player have a rule when actor recieves event touch is pressed change move on to 1

    have another rule in the player when attribute move on=1 AND touch is outside AND touch is released

    interpolate self position x to mouse position x
    interpolate self position y to mouse position y
    change attribute moveon to 0

    cheers
  • CuckooheadCuckoohead Member Posts: 16
    JohnPapiomitis said:
    make a interger attribute call it moveon or whatever

    in the player have a rule when actor recieves event touch is pressed change move on to 1

    have another rule in the player when attribute move on=1 AND touch is outside AND touch is released

    interpolate self position x to mouse position x
    interpolate self position y to mouse position y
    change attribute moveon to 0

    cheers

    I did exactly what you told me, but my character won't move. What could be wrong? I made a game attribute called "Move On" then made a rule to make it equal to 1 when it is pressed. In another rule I made when "move on" equals 1, and touch is outside, and touch is released, then self.position.X is interpolated to mouse.position.X, with the same for Y. The rule also has a change attribute that switches "Move On" back to 0.

    See any problems?
  • CuckooheadCuckoohead Member Posts: 16
    Do I have to test it on my iPhone? Or should it work on the regular preview option?
  • mlaftamlafta Member Posts: 147
    Try to put the rules on the instance of the actor not the prototype. Also try to change touch to mouse, in some cases it works
  • mlaftamlafta Member Posts: 147
    Is your actor set to movable in the physics attributes?
  • CuckooheadCuckoohead Member Posts: 16
    I tried what you said and it still isn't working :(

    This is harder to accomplish than I thought.
  • CuckooheadCuckoohead Member Posts: 16
    Yup, it's movable.
  • mlaftamlafta Member Posts: 147
    In the rules, instead of interpolate x,y try use using Move To
  • CuckooheadCuckoohead Member Posts: 16
    Switching interpolate for Move To doesn't change anything. My character still won't budge...

    I had it moving to wherever I clicked using two constrain attributes, earlier. I liked the way it responded, however, my character would move WHENEVER I clicked on the screen. When I'd try to click on some of her abilities in the action bar I created, she'd move to the button. I'm trying to find a way to only make her movable if she is touched and the dragged to a location...
  • mlaftamlafta Member Posts: 147
    To do a little debug, add display text on the second rule, and see if this is rule ever invoked.
  • CuckooheadCuckoohead Member Posts: 16
    I just added a display text as you advised and it didn't show up when I clicked, dragged, and released my character. It seems that the rule isn't being activated.
  • mlaftamlafta Member Posts: 147
    Let's think for a minute about the conditions of the rule. We are asking for the rule to be activated when

    The touch is outside the actor And the touch is released ..hmm this doesn't seem right because how can you touch and release at the same time?

    So let's think of something else.

    Try to create the 2nd rule in a different way

    Create a rule when touch is pressed and Move on is 1 then put another rule in the behavior section and say when touch released then move actor.

    Try it and let me if it works.

    Mo
  • CuckooheadCuckoohead Member Posts: 16
    No, it doesn't work... I must be doing something wrong :(

    The two behaviors I have in my character are:

    1. A rule that changes attribute "move on" to 1 when touch is pressed.

    2. A rule that is activated when both touch is pressed AND "move on" is equal to 1. Within this rule is another rule with two interpolate attributes (one that interpolates Self.Position.X to Mouse.Position.X, and one that interpolates Self.Position.Y to Mouse.Position.Y. They are both set to function linearly, with a duration of 1), bellow the interpolate attributes is a change attribute that changes "move on" back to 0.

    There are no "otherwise" settings in any of my rules.

    Can you see what could be the problem? I don't understand what I'm doing wrong. It seems logical enough :P
  • mlaftamlafta Member Posts: 147
    Cuckoohead said:
    No, it doesn't work... I must be doing something wrong :(

    The two behaviors I have in my character are:

    1. A rule that changes attribute "move on" to 1 when touch is pressed.

    2. A rule that is activated when both touch is pressed AND "move on" is equal to 1. Within this rule is another rule with two interpolate attributes (one that interpolates Self.Position.X to Mouse.Position.X, and one that interpolates Self.Position.Y to Mouse.Position.Y. They are both set to function linearly, with a duration of 1), bellow the interpolate attributes is a change attribute that changes "move on" back to 0.

    There are no "otherwise" settings in any of my rules.

    Can you see what could be the problem? I don't understand what I'm doing wrong. It seems logical enough :P

    OK -:)

    Let's do it again.

    1. click on on the actor to unlock it and change the instance not the prototype.

    2. Rule 1 ( when touch is pressed then set Move on to 1 )
    2. Rule 2 ( when Move On is 1 and touch is outside then add another rule within that says ( when touch is released then display text "WORKS" )

    Let's do this see if this works then we will change the last rule.

    Mo
  • mlaftamlafta Member Posts: 147
    OK -:)

    Let's do it again.

    1. click on on the actor to unlock it and change the instance not the prototype.

    2. Rule 1 ( when touch is pressed then set Move on to 1 )
    3. Rule 2 ( when Move On is 1 and touch is outside then add another rule within that says ( when touch is released then display text "WORKS" )

    Let's do this see if this works then we will change the last rule.

    Mo
  • CuckooheadCuckoohead Member Posts: 16
    mlafta said:
    OK -:)

    Let's do it again.

    1. click on on the actor to unlock it and change the instance not the prototype.

    2. Rule 1 ( when touch is pressed then set Move on to 1 )
    3. Rule 2 ( when Move On is 1 and touch is outside then add another rule within that says ( when touch is released then display text "WORKS" )

    Let's do this see if this works then we will change the last rule.

    Mo

    I did exactly what you said, but nothing happens. The text never shows up. Could there be something else wrong with my project? I even created a new game, made a background, one actor, and tried doing what you said, but it still didn't display any text like it was programmed to.

    This sure is mind boggling! But fun in a weird way, too. I'm so glad you are helping me with this! I appreciation it tremendously!
  • mlaftamlafta Member Posts: 147
    hmmm I don't know what to think now. I am fairly new at this as well, but I think I did experiment with this and it worked.

    Add an actor to scene and make it display the Move On attribute to see if this guy changes.

    Mo
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Sorry mate i was half asleep when i posted last night. I made a demo for you

    http://www.mediafire.com/?wqdbr2np21yg735

    if you have any questions feel free to ask
    cheers
  • mlaftamlafta Member Posts: 147
    I will try this at home on my Mac. I wonder how you did it :)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    i did it just how i posted above., i just forgot to put in my post you need 2 real attributes (ill call them targetx and targety) to register the touch position x and y when you let go, so you know thats exactly where its supposed to go to and doesnt get thrown off by any other touch.

    then one more rule when self position x and y = targetx and targety
    change attribute move on to 0 (move on attribute is from my older post)

    that shuts it all down and resets for the next touch and drag

    and incase your wondering mouse position x and touch x are the same thing on the device. It reads both the same

    cheers
  • mlaftamlafta Member Posts: 147
    Thanks a lot, I will try it later. This is a lot of fun! :)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    glad your having fun! thats what its all about :)
  • CuckooheadCuckoohead Member Posts: 16
    JohnPapiomitis said:
    Sorry mate i was half asleep when i posted last night. I made a demo for you

    http://www.mediafire.com/?wqdbr2np21yg735

    if you have any questions feel free to ask
    cheers

    John, you are my hero! Thanks for helping me out, now I understand how it works :D
  • mlaftamlafta Member Posts: 147
    Cuckoohead said:
    John, you are my hero! Thanks for helping me out, now I understand how it works :D

    Just curious, what was it that you were doing wrong?
Sign In or Register to comment.