playMaker

Author Topic: Layer mask with Touch Object 2D event?[SOLVED]  (Read 2414 times)

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Layer mask with Touch Object 2D event?[SOLVED]
« on: March 16, 2014, 06:13:55 AM »
I'd like to try using the touch events for my puzzle game. I'm trying to figure out a way to have certain pieces (sprites) that are in range, touchable (play animation & do stuff) and pieces out of range are untouchable. Any ideas how to mask them like this?
I had the idea to do a layer mask. ie, set layer to ignore raycast if piece out of range. How could i do a layer mask with Touch Object 2D event? Or is there an even better way? Is the touch event even related to raycast? Thanks
« Last Edit: March 25, 2014, 08:39:06 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Layer mask with Touch Object 2D event?
« Reply #1 on: March 18, 2014, 08:36:20 AM »
Hi,

 I think you should simply ask the piece itself if it can be interacted with and how? so when a piece it touched, you first send an event to that piece, and it decides how to react.

 ele, you can simply use tags. I would prefer this than layers actually, and then you can filter your touch events with tags, using actions like trigger 2d events and similar.

bye,

 Jean

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: Layer mask with Touch Object 2D event?
« Reply #2 on: March 19, 2014, 12:26:51 AM »
Thanks for the reply, Jean.
I'm a little confused by your second suggestion. How do I filter touch event with tag with trigger 2d event? Do I set the collider, on the sprite, to "Is Trigger" and somehow tag the finger/touch event? Not sure how to tag the touch. Plus a side note, I have to use Touch object for 2d event since i'm using 2d physics, don't I?
Thanks again.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Layer mask with Touch Object 2D event?
« Reply #3 on: March 19, 2014, 04:51:52 AM »
Hi,

 I think I got confused between "Touch" and "Trigger",

Touch Object 2d acts only on the gameobject you use this action, so there no filter to apply here.

so what would be the use case for a laermask on a touch Object 2D because you are already reference the object itself ( the owner of this fsm basically).

bye,

 Jean

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: Layer mask with Touch Object 2D event?
« Reply #4 on: March 20, 2014, 09:27:09 PM »
So, then your first paragraph of first response will actually work for me. I'll just ask a piece when touched if it's in range and then act accordingly. (I didn't consider this because I thought if it's out of range then it wouldn't respond at all, but that makes sense that it would just check and go back to static if false)I just wanted to make sure I understood what you meant by the trigger filter 2d, and if we were still talking about Touch stuff. I probably confused you when I was talking about range. 
So your first comment helped! I'm good now.