Playmaker Forum

PlayMaker Help & Tips => iOS Help => Topic started by: Abdou23 on August 20, 2014, 12:52:48 AM

Title: Get touch position (Right - Left)
Post by: Abdou23 on August 20, 2014, 12:52:48 AM
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 :)
Title: Re: Get touch position (Right - Left)
Post by: cloud03 on August 20, 2014, 09: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 :)
Title: Re: Get touch position (Right - Left)
Post by: Abdou23 on August 20, 2014, 02:11:26 PM
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 ?
Title: Re: Get touch position (Right - Left)
Post by: cloud03 on August 21, 2014, 09: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?
Title: Re: Get touch position (Right - Left)
Post by: Abdou23 on August 23, 2014, 12:23:27 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?

i would like to use touch ended to add extra movement action. How to achieve that ?
Title: Re: Get touch position (Right - Left)
Post by: cloud03 on August 23, 2014, 09: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..
Title: Re: Get touch position (Right - Left)
Post by: Abdou23 on August 24, 2014, 03: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.