Playmaker Forum

PlayMaker Help & Tips => iOS Help => Topic started by: NAME on December 11, 2013, 02:01:37 PM

Title: 2D movement
Post by: NAME on December 11, 2013, 02: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
Title: Re: 2D movement
Post by: jeanfabre on December 11, 2013, 02: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
Title: Re: 2D movement
Post by: NAME on December 13, 2013, 12:21:40 PM
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
Title: Re: 2D movement
Post by: jeanfabre on December 14, 2013, 01:16:15 PM
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
Title: Re: 2D movement
Post by: NAME on December 14, 2013, 03: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
Title: Re: 2D movement
Post by: jeanfabre on December 15, 2013, 05: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
Title: Re: 2D movement
Post by: NAME on December 15, 2013, 10: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
Title: Re: 2D movement
Post by: jeanfabre on December 16, 2013, 06:55:05 AM
Hi,

 ok, yes, prefer using springs then,

bye,

 Jean