playMaker

Author Topic: Get touch position (Right - Left)  (Read 2042 times)

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Get touch position (Right - Left)
« on: August 19, 2014, 09:52:48 PM »
So, Basically i want to cut the screen into 2 halts, if i touch the right half the player moves right, if i touch the left half the player moves left.

here is what i've done:

[State 1]
1-Touch Event >
[State 2 ]
2-Get Touch info > Store the X position >
3-Screen to World point > use the stored variable above as the "Screen X" >
4-Random Float > The space from centre of the screen to the far left as minimum & maxim > Store in new variable >
5-Float Compare > compare the touched variable with the random variable > if Equals then send event

[State 3]
6- Translate > finished go back to [State 1 - Touch Event ]

My problem is, it doesn't work at all :)

cloud03

  • Full Member
  • ***
  • Posts: 230
  • Viva Playmaker!
    • View Profile
    • Milkish Game Studios Blog
Re: Get touch position (Right - Left)
« Reply #1 on: August 20, 2014, 06:59:14 AM »
Here is what I've done, and it is working:

[State 1]
Get Touch info - store x position to a variable, and check "normalize" checkbox
Touch Event - on touch go to 2nd State

[State 2]
Float Compare - compare the variable we stored before to a value 0.5, if its less, go to transition left, otherwise go right, and set the state to move to the respective direction.

hope this helps :)

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Re: Get touch position (Right - Left)
« Reply #2 on: August 20, 2014, 11:11:26 AM »
Works fine now, thank you :)

But here is something i wanted to do, while testing with Axis input i found out when i release the button the Player keeps moving for like 0.2 seconds more, but in touch it doesn't happen, i want when the touch ends the player moves little further, tried implementing "Touch Ended/Canceled" event but failed.

Any ideas ?

cloud03

  • Full Member
  • ***
  • Posts: 230
  • Viva Playmaker!
    • View Profile
    • Milkish Game Studios Blog
Re: Get touch position (Right - Left)
« Reply #3 on: August 21, 2014, 06:09:20 PM »
Sorry, but I'm not quite sure with what you meant, could you explain a bit more on what are you trying to achieve?

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Re: Get touch position (Right - Left)
« Reply #4 on: August 23, 2014, 09:23:27 AM »
Sorry, but I'm not quite sure with what you meant, could you explain a bit more on what are you trying to achieve?

i would like to use touch ended to add extra movement action. How to achieve that ?

cloud03

  • Full Member
  • ***
  • Posts: 230
  • Viva Playmaker!
    • View Profile
    • Milkish Game Studios Blog
Re: Get touch position (Right - Left)
« Reply #5 on: August 23, 2014, 06:11:39 PM »
Well in that case, simply set a new state and on touch ended go to that state. Inside the newly created state add an Interpolate float from the current speed to a value of 0 within a certain duration, and translate the game object using that interpolated value..

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Re: Get touch position (Right - Left)
« Reply #6 on: August 24, 2014, 12:39:02 PM »
Well in that case, simply set a new state and on touch ended go to that state. Inside the newly created state add an Interpolate float from the current speed to a value of 0 within a certain duration, and translate the game object using that interpolated value..

Thank you.