Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: HeathClose on April 18, 2017, 06:19:05 PM

Title: Detecting Fast 2d Triggers [SOLVED]
Post by: HeathClose 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...
Title: Re: Detecting Fast 2d Triggers
Post by: jeanfabre 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
Title: Re: Detecting Fast 2d Triggers
Post by: HeathClose 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?
Title: Re: Detecting Fast 2d Triggers
Post by: tcmeric 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?
Title: Re: Detecting Fast 2d Triggers
Post by: tcmeric 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.
Title: Re: Detecting Fast 2d Triggers
Post by: HeathClose 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...
Title: Re: Detecting Fast 2d Triggers
Post by: HeathClose 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
Title: Re: Detecting Fast 2d Triggers
Post by: tcmeric on April 20, 2017, 10:57:04 AM
Ok, ill have another crack at it. I think I found the problem.
Title: Re: Detecting Fast 2d Triggers
Post by: tcmeric 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).
Title: Re: Detecting Fast 2d Triggers
Post by: HeathClose 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
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: tcmeric 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  ::)
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: HeathClose 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...
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: jeanfabre 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
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: tcmeric 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.  :)
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: jeanfabre 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
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: tcmeric on April 25, 2017, 03:40:06 AM
Thanks, I am interested to see what you change, because I didnt know how to do that.
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: jeanfabre on April 25, 2017, 05:56:23 AM
Hi,

 It's now up on the Ecosystem, it comes with an editor file where all the work is done for showing the cylinder. I also modified the effect of Space property so that it affect both the position and rotation, making it very easy to do offsets and all.

now debug works in editor when you don't play, so you can set it up very easily during editing.

Drawing the cylinder is not easy, but manageable, I took the internal code from Unity Handles class to get it done faster, interesting vector maths when you can't use a transform.

If you have questions, let me know :)

Bye,

 Jean
Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: jeanfabre on May 03, 2017, 03:59:12 AM
HI,

 ok, It's on the Ecosystem now, Went over the top with the debug volume (https://twitter.com/JeanAtPlayMaker/status/859676245155598336), but it shows how far you can take it with accurate representation of the casting volume in all situations.


 I modified the behavior of the self vs world space value, which I think gives more flexibility and power to the action.

Bye,

 Jean

Title: Re: Detecting Fast 2d Triggers [SOLVED]
Post by: tcmeric on May 03, 2017, 08:22:47 AM
Very cool debug!