playMaker

Author Topic: Detecting Fast 2d Triggers [SOLVED]  (Read 4700 times)

HeathClose

  • Full Member
  • ***
  • Posts: 226
Detecting Fast 2d Triggers [SOLVED]
« on: April 18, 2017, 06:19:05 PM »
So this is a question I asked over on the unity forums about my huge triggers passing right through my player undetected some of the time... and they gave me an answer that I just don't get... is what they are suggesting doable with Playmaker?

https://forum.unity3d.com/threads/detecting-fast-2d-triggers.466672/#post-3035879

If not, does anyone else have experience with getting triggers to work right?  They are not small.. and they are not fast... but they don't always detect...
« Last Edit: April 20, 2017, 11:46:56 AM by HeathClose »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Detecting Fast 2d Triggers
« Reply #1 on: April 19, 2017, 02:44:12 AM »
Hi,

 basically, you need use casting with a ray to detect what  is in front of the bullet to make sure, you can't rely on physics triggers just like if you start experiencing triggers going through too fast.

 simply make the bullet collider very stretched in the forward direction and it will work. else make your triggers generally a lot bigger than the physical shape they encompass.

 Bye,

 Jean

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: Detecting Fast 2d Triggers
« Reply #2 on: April 19, 2017, 01:06:20 PM »
Hi,

 basically, you need use casting with a ray to detect what  is in front of the bullet to make sure, you can't rely on physics triggers just like if you start experiencing triggers going through too fast.

 simply make the bullet collider very stretched in the forward direction and it will work. else make your triggers generally a lot bigger than the physical shape they encompass.

 Bye,

 Jean

Thanks Jean... I converted my huge triggers to raycasts... interval at 1... I'll have to do some more testing to see if the cost is worth it but I got it working, thank you...

Since my triggers were huge... I've gone from a very large trigger area to a single ray.... so the raycast of these huge bullets is passing right over or right under the character when they should be returning a hit... I did a little research and found something called a circle cast... but I don't see that on the ecosystem... i tried the spherecast, but either i don't have it set up right or it doesn't work in a game set to 2d

can anyone cook up a 2d circle cast for me?

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Detecting Fast 2d Triggers
« Reply #3 on: April 20, 2017, 07:27:12 AM »
I might be able to. I dont do any 2d stuff, so you will need to test it out (if I can get it that far). Let me give it a try and see. Ill post back here when done. Maybe a day or so?

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Detecting Fast 2d Triggers
« Reply #4 on: April 20, 2017, 08:34:36 AM »
Here this might work. Not throwing any errors at least. I basically just hijacked the raycast 2d action and changed it to be a circlecast. The only real difference is that it has a "radius" value, which determines the size of the cast. It should theoretically work with the other raycast actions in playmaker.

Jean, how do I license this action? It is a playmaker native action with some basic changes.

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: Detecting Fast 2d Triggers
« Reply #5 on: April 20, 2017, 08:42:44 AM »
Here this might work. Not throwing any errors at least. I basically just hijacked the raycast 2d action and changed it to be a circlecast. The only real difference is that it has a "radius" value, which determines the size of the cast. It should theoretically work with the other raycast actions in playmaker.

Jean, how do I license this action? It is a playmaker native action with some basic changes.

Thank you so much for the spending the calories on this!!

I'll get it in the game today and let you know how it goes...

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: Detecting Fast 2d Triggers
« Reply #6 on: April 20, 2017, 10:27:32 AM »
Here this might work. Not throwing any errors at least. I basically just hijacked the raycast 2d action and changed it to be a circlecast. The only real difference is that it has a "radius" value, which determines the size of the cast. It should theoretically work with the other raycast actions in playmaker.

Jean, how do I license this action? It is a playmaker native action with some basic changes.
ok so i brought it into the game and no matter how I play with the numbers... it just casts a single ray

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Detecting Fast 2d Triggers
« Reply #7 on: April 20, 2017, 10:57:04 AM »
Ok, ill have another crack at it. I think I found the problem.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Detecting Fast 2d Triggers
« Reply #8 on: April 20, 2017, 11:01:46 AM »
Ok, hopefully this should do it. If you were not setting a max/min, then it was still doing a raycast instead of circle cast. I changed that line to be circlecast now (instead of raycast).

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: Detecting Fast 2d Triggers
« Reply #9 on: April 20, 2017, 11:46:40 AM »
Ok, hopefully this should do it. If you were not setting a max/min, then it was still doing a raycast instead of circle cast. I changed that line to be circlecast now (instead of raycast).

This.  Works.  Perfectly!  Thank you so very much for helping me!

I don't know if circle casts are supposed to debug showing a circle, as the debug shows a ray, but it's fairly easy to figure out with just the ray

and now even bullets that are just barely hitting her feet show a detection... a FAR cry from the trigger issues I was having... I can't thank you enough... what a stressor that was... now relieved.

the circle allows for far less repeat intervals, too.. another bonus is better performance...

thanks again
« Last Edit: April 20, 2017, 11:48:42 AM by HeathClose »

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #10 on: April 20, 2017, 11:58:23 AM »
No problem. Most of the heavy lifting was already done by the playmaker action that I copied. I am glad it works for you. I am happy to help, I learned something new.

Sorry, no idea about the debug  ::)

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #11 on: April 20, 2017, 12:04:39 PM »
hahaha... no problem, debug is easy enough to just "picture" a circle, and testing confirmed my guesses...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #12 on: April 21, 2017, 03:10:35 AM »
Hi,

 You can copy paste PlayMaker actions and add change features to them, and then apply your licensing to it, that's fine, as long as you reference the original action, you will be fine ( and even though it's not mandatory).

I'll put this action on the Ecosystem, Thanks for all your work! we really appreciate it!



 Bye,

 Jean

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #13 on: April 21, 2017, 04:09:41 AM »
Cool. Thanks for the heads up. I will do that in the future. Please add any licensing you want before uploading. MIT, etc. Thanks for uploading it for us.  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #14 on: April 25, 2017, 03:12:37 AM »
Hi,

 I am on it, but I need modify it so that it takes into account the object rotation if you don't express a direction, and also properly show the casting debug volume.

 Bye,

 Jean