playMaker

Author Topic: Drag and drop 2d sprites require rigidbody and collider?  (Read 5263 times)

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Drag and drop 2d sprites require rigidbody and collider?
« on: December 29, 2013, 06:16:54 AM »
I have a simple puzzle where the player is presented with a series of different tiles and the player is challenged to drag the tiles to the right slot.  This is in iOS so I am using get touch info and setting the position of the tile sprite to drag with the player's finger.

I am trying to detect if the sprite is dropped in the target area by using Trigger Enter 2D.  If there's Trigger Enter 2D without a Trigger Exit 2D, and there's a Touch End event, the sprite must be dropped over the target area. 

My problem with this is to do this properly it seems everything has to be a rigidbody. And I don't want the pieces to interact with each other with physics.  (It's just a board game).

What I've found is if both the piece and the slot are box collider 2ds only (not rigidbodies) then the trigger enter does not work.  If the slot is a box collider and rigidbody, and the piece is just a box collider only, then on trigger enter works, but not on trigger exit for some reason.

Is there a better way to do what I am trying to achieve?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Drag and drop 2d sprites require rigidbody and collider?
« Reply #1 on: December 30, 2013, 07:21:07 AM »
Hi,

 Set you physics component to "is kinematic" and you are good to go. Then it doesn't affect your gameobject with a physics behavior, it will only let you use colliders and triggers properly.

 else, you should use raycasting, but that's more work and less convenient/powerful/flexible...


Bye,

 Jean