playMaker

Author Topic: iOS - 2D movement in 3D world based on touch input [SOLVED]  (Read 6046 times)

IPete2

  • Playmaker Newbie
  • *
  • Posts: 23
iOS - 2D movement in 3D world based on touch input [SOLVED]
« on: April 25, 2011, 04:29:23 PM »
Hi guys,

I have a 2D character moving just fine using horizontal and vertical axis input, but I need to change this to work on touch screens, namely iPad.  Character moves along X-Z axis, I need to touch the screen and move the character towards that point on screen.


I was using GetAxis for using the cursor keys, but now I need equivalent touch input.  Nothing I can see works how I need it to.  I have tried all sorts and failed.  

Please help.

:)

Thanks

IPete2
« Last Edit: May 01, 2011, 06:03:46 PM by IPete2 »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: iOS - 2D movement in 3D world based on touch input
« Reply #1 on: April 26, 2011, 02:47:01 PM »
Not on a mac at the moment, so can't test this, but want to say that MousePick will work on iPad. If it does you can follow this tutorial:
http://www.youtube.com/user/HutongGamesLLC?feature=mhum#p/a/u/1/qMi0L4ALgEA

Otherwise use Get Touch Info to get the screen position of the touch, and use Screen Pick to cast a ray into the world. Then move your character towards that point. You can gate the whole thing with a Touch Event if necessary...

IPete2

  • Playmaker Newbie
  • *
  • Posts: 23
Re: iOS - 2D movement in 3D world based on touch input
« Reply #2 on: April 26, 2011, 05:20:48 PM »
Thanks Alex,

I will try these ideas tomorrow.

BTW PlayMaker "Rocks!" - I love it so far, and hope to use it to create a couple of Apps in the next three months.  I will keep you in touch with how I get on,

Best regards,

Peter.

iByte

  • Playmaker Newbie
  • *
  • Posts: 3
Re: iOS - 2D movement in 3D world based on touch input
« Reply #3 on: April 27, 2011, 11:25:38 AM »
Hi Alex, I am needing something similar and have been using a modified version of the Seeksteer script from the Unity Wiki. I updated it to take keyboard input and adjust the direction accordingly. Works fine for keyboard driven games but now I want to use touch on the iPad to direct the player along the Seeksteer path (drag/swipe up/down) vs up/down arrow keys and be able have the player character (model) rotate along the y axis using a swipe gesture (left/right) vs right/left arrow keys.

Any suggestion on how this might be accomplished with playMaker would be most welcome.

iByte

IPete2

  • Playmaker Newbie
  • *
  • Posts: 23
Re: iOS - 2D movement in 3D world based on touch input [SOLVED]
« Reply #4 on: April 30, 2011, 06:24:52 AM »
OK,

I'm happy to say with a bit of fiddling around I have now successfully got an iOS 2D touch screen - object moves to target working.

If you have seen the Mouse Pick video, I followed that but here are some tips.  Instead of Mouse Down, use TouchEvent in the input manager (see video).  But a couple of things, you have to have an object for the mouse pick to 'see' in the world, or it doesn't pick anything, obvious really, so I set up a plane below my objects which filled my touch screen area.  Setting the render mesh off doesn't stop the mouse pick working, but it stops the plane interfering with your design plans.

Hope that helps someone get there quicker. Thanks for the input Alex, being very new to PlayMaker, it got me working in the right direction.
« Last Edit: April 30, 2011, 06:27:36 AM by IPete2 »