playMaker

Author Topic: 2D movement  (Read 1657 times)

NAME

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
2D movement
« on: December 11, 2013, 12:01:37 PM »
Hello

What is the best way to do a 2D XY character movement on a iOS device? I am a bit confused. I want the 2D character to move to where I touch the screen. What actions should I use? I am able only to set a WASD/arrow key movement.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: 2D movement
« Reply #1 on: December 11, 2013, 12:22:02 PM »
Hi,

 quite involving despite what seems to be an easy thing.

 you'll need a special custom action to transform a screen point into a point in space on a defined plane ( the ground).

http://hutonggames.com/playmakerforum/index.php?topic=272.0

then once you have that world position, you use the "move towards" action to move the character, but that's not just it, you will need to animate it likely, so your character behavior has to be designed so that it doesn't responds to input to rely on its animation, but on its own movement.


bye,

 Jean

NAME

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: 2D movement
« Reply #2 on: December 13, 2013, 10:21:40 AM »
Hello

I would also like to know how to set a collision between a 2D character and 2D object? I do not want the 2D character to go through the 2D object.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: 2D movement
« Reply #3 on: December 14, 2013, 11:16:15 AM »
Hi,

 Both objects have to have a physics 2d and collider 2d not set to "is trigger" and they won't overlap each other.

bye,

 Jean

NAME

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: 2D movement
« Reply #4 on: December 14, 2013, 01:38:32 PM »
Hello

Yes but this is working only when for example I set a 2D character in the air over a 2D object and when I play the scene the 2D character falls on the 2D object and does not go through. But when I am moving the 2D character with touch on a iOS device it always goes through the 2D object like it is not an obstacle.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: 2D movement
« Reply #5 on: December 15, 2013, 03:30:19 AM »
Hi,

 how do you actually move that object with the touch?

You should try using a spring and move the spring and have your 2d object attached to that spring, then all collision should work better.

bye,

 Jean

NAME

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: 2D movement
« Reply #6 on: December 15, 2013, 08:04:11 AM »
Hello

The way it moves is a 2D version of this:

Tutorials/iOS Fundamentals/09 - Touch Info (starts at 26:40)

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: 2D movement
« Reply #7 on: December 16, 2013, 04:55:05 AM »
Hi,

 ok, yes, prefer using springs then,

bye,

 Jean