Follow Finger?

11clock11clock Member Posts: 450
edited November -1 in Working with GS (Mac)
In my game I have it so if you tap somewhere, the character will move to that location. The problem with this is that you have to constantly tap to move around. I want to make it so the character can follow the finger as you drag it around the screen. How do you do this?

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    Constrain the X and Y of the Touch on the screen.
  • 11clock11clock Member Posts: 450
    DrGlickert said:
    Constrain the X and Y of the Touch on the screen.

    Already done, but that doesn't work. Change Velocity doesn't update itself.
  • 11clock11clock Member Posts: 450
    I still need help. Anyone know how?
  • PeeCeePeeCee Member Posts: 107
    Hi there.

    can you post what your code looks like so we can assist.
  • 11clock11clock Member Posts: 450
    I replaced Change Velocity to Move To. It now works when I drag my finger, but when the character arrives at the finger, I'll have to remove my finger and tap somewhere else to get it moving again. There a way to fix this?
  • PeeCeePeeCee Member Posts: 107
    all you need is to contrain the actor (the one you want to move with your finger) to

    1.self.motion.linear.velocity.x to game.touches.touch1.x - self.postion.x
    2.self.motion.linear.velocity.y to game.touches.touch1.y - self.postion.y

    you dont need a change velocity nor a move to because your simply contraining the device
    touch coordinates to the position of your finger.
  • 11clock11clock Member Posts: 450
    pcbuddyc said:
    all you need is to contrain the actor (the one you want to move with your finger) to

    1.self.motion.linear.velocity.x to game.touches.touch1.x - self.postion.x
    2.self.motion.linear.velocity.y to game.touches.touch1.y - self.postion.y

    you dont need a change velocity nor a move to because your simply contraining the device
    touch coordinates to the position of your finger.

    That will cause the actor to move faster diagonally.

    Anyways, I solved the issue using a timer. Thanks, anyways!
  • rlehmrlehm Member Posts: 320
    Do you want to add a top speed that the actor will travel?
  • rlehmrlehm Member Posts: 320
    self.Motionline.velocity.x = self.Speed *( game.Mouse.Position.X - self.Position.X )

    self.motionline.velocity.y = self.Speed *( game.Mouse.Position.Y - self.Position.Y )

    create self attribute 'speed'

    set speed to about 3
Sign In or Register to comment.