move to game.touch.x constantly, is this poss?

SparkyidrSparkyidr Member, PRO Posts: 2,033
edited November -1 in Working with GS (Mac)
Hi
I want an actor to constantly follow my touch left and right.

At te mo, I have it set up just to contrain it's x position to my touch.x position.
This works really well when you are sliding the touch lef tand right, and pretty much looks like I want it to.

My problem is, becuase I am using a constrain, when I don't "slide", I can just tap the screen, and the actor obviously just appears at the touch.

Is there a way to do it so it feels like a constrain, but if I touch away, it moves to the touch fairly quick?

I tried using a move to , saying move to a Y position, and X set to the touch.x. and this works but only once, with or without run to completion set.
The move to works if I wrap it in a timer...I.E.

every 0.01 seconds move to, Y-165, X-Touch.X
but that seems like a rubbish way to do it.

I might be missing something really obvious

Anyone got any thoughts?

Sparky

Comments

  • SparkyidrSparkyidr Member, PRO Posts: 2,033
    when I say it works once....
    I mean it gets to the x position, and stops... I can then re-touch somewhere else, and it will will move there and stop.

    But I want to be able to constantly slide my touch and have the actor follow
  • GamexcbGamexcb Member Posts: 179
    You need to use move to vector.

    Use a move behavior.
    Then set the direction to:

    vectorToAngle( game.Touch.X - self.Position.X , game.Touch.Y - self.Position.Y )
    ---------

    That should do the trick!

    -Gamexcb
  • SparkyidrSparkyidr Member, PRO Posts: 2,033
    ahh thanks.
    Will give that a try
  • SparkyidrSparkyidr Member, PRO Posts: 2,033
    yay.. thanks @Gamexcb

    Had a tinker around with the vectortoangle, and got it working pretty much as I had imagined it.

    Much love.
  • AfterBurnettAfterBurnett Member Posts: 3,474
    I have tried this... it works but it jumps around a lot when it reaches its destination... any ideas?
  • StorerDevStorerDev Member Posts: 10
    How do you make it accelerate to the point though i cant figure that out.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    this thread was almost a year old! you should never reply to a thread this old. the information is old and outdated. always start a new thread. you will get more answers because people see a new thread, but also conflicting and often bad information is not moved to the top.

    closing.
Sign In or Register to comment.