playMaker

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

HeathClose

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Detecting Fast 2d Triggers [SOLVED]
« on: April 18, 2017, 03: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, 08:46:56 AM by HeathClose »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11918
  • Official Playmaker Support
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #1 on: April 18, 2017, 11:44:12 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

HeathClose

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #2 on: April 19, 2017, 10:06:20 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

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

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #3 on: April 20, 2017, 04: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

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #4 on: April 20, 2017, 05: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: 214
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #5 on: April 20, 2017, 05: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: 214
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #6 on: April 20, 2017, 07: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

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #7 on: April 20, 2017, 07:57:04 AM »
Ok, ill have another crack at it. I think I found the problem.

tcmeric

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #8 on: April 20, 2017, 08: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: 214
    • View Profile
Re: Detecting Fast 2d Triggers
« Reply #9 on: April 20, 2017, 08: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, 08:48:42 AM by HeathClose »

tcmeric

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #10 on: April 20, 2017, 08: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: 214
    • View Profile
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #11 on: April 20, 2017, 09:04:39 AM »
hahaha... no problem, debug is easy enough to just "picture" a circle, and testing confirmed my guesses...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 11918
  • Official Playmaker Support
    • View Profile
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #12 on: April 21, 2017, 12: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

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #13 on: April 21, 2017, 01: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: 11918
  • Official Playmaker Support
    • View Profile
Re: Detecting Fast 2d Triggers [SOLVED]
« Reply #14 on: April 25, 2017, 12: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