Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mallenroh on March 25, 2018, 01:44:37 PM

Title: get next raycast/linecast2d reset
Post by: mallenroh on March 25, 2018, 01:44:37 PM
Hello,
Is it possible to reset a get next raycast2d and or get next linecast 2d action?
Specifically if I use either of these 2 actions in a loop, when I try to use it again thru the same loop state, , I get an index error/out of range exception.

I noticed there was a get next array2 action that had a reset bool variable for this purpose, how would I do something similar with linecast and or raycast 2d?

Thanks,
Title: Re: get next raycast/linecast2d reset
Post by: djaydino on March 26, 2018, 01:39:19 AM
Hi.
I will make custom actions for both when i get home (just on my way to work now)

And place it on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)
Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on March 28, 2018, 09:12:50 AM
Thanks so much for looking into this!
Title: Re: get next raycast/linecast2d reset
Post by: djaydino on March 28, 2018, 02:59:20 PM
Hi.
Sorry i actually forgot about this.

i edited and made them now :)

don't be afraid to bump a post.

Can you try them if the work (get the package below), if so let me know so i can add them to the Ecosystem.

if not let me know also of course :)
Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on March 29, 2018, 12:37:51 AM
Thanks again for taking a stab at this, but it still acts like there is no reset declared. The bool is enabled , but it does not make a difference. It still returns the index error like before. This is for both variations (raycast/linecast)
thanks again!
Title: Re: get next raycast/linecast2d reset
Post by: djaydino on March 29, 2018, 02:31:15 AM
hi,
Can you show me some images or video from your fsm/states/actions setup?

or pm me a link to your project. or if you can make a simple scene (with simple cubes) with your setup.
So i can test and see whats wrong. (action and/or setup)

Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on March 29, 2018, 10:23:09 AM
Hey,
So its just a simple test fsm, first state is on key down, sends to the raycastGetNext state, which just dumps all items hit by the raycast into a array, then returns to the start when done.

The second time around, it still gets hung on the second state with the index error.
I did notice that the bool reset flag, even when initially checked, was unchecked on the second pass thru...
So maybe its resetting the flag instead of the internal array of hit colliders?

Title: Re: get next raycast/linecast2d reset
Post by: djaydino on March 29, 2018, 03:00:24 PM
Hi,
The image is very small to see, you can use imgur to upload images.

But i can see that you have the reset flag wrong.

You should use a variable there.
and each time before you start the state with the get next action , you need to set that variable to 'true' if you want to reset it.

Once the action starts it will check if the variable is set to true.
if true it will reset and set the variable to false.
Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on March 30, 2018, 02:43:09 AM
Thanks for the reply!
So I added a counter for every time the loop used a raycast, and put a condition for when it had done so to set the bool variable used in the loop state to true (using set fsm bool). But it still reverts to false after the first iteration.
Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on March 31, 2018, 12:03:10 PM
Hello,
The next linecast2 action behaves the same as well, in spite of using a bool variable for the state of the reset flag, it wont actually reset, and gets stuck the second time it enters the loop state.
Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on April 01, 2018, 12:08:48 PM
Ive rearranged the fsms to be a little more legible,

there is just a key down action that starts the test,

the raycastloop img is using a custom bool variable for the reset flag
the raycastpreloop img is setting the bool variable to true before a second iteration.

the fsm still gets stuck on the second iteration though
Title: Re: get next raycast/linecast2d reset
Post by: mallenroh on April 04, 2018, 07:38:44 AM
Bump to the top...
Title: Re: get next raycast/linecast2d reset
Post by: jeanfabre on April 05, 2018, 02:43:52 AM
Hi,

 can you send me a package of this scene, and I'll check what's wrong. Thanks :)

 Bye,

 Jean
Title: Re: get next raycast/linecast2d reset
Post by: djaydino on April 05, 2018, 04:19:49 AM
Hi.
I found the issue, it is actually a bug in the original action that does not 'reset' properly when finished.

So i will report the bug, and the actions package below should work now.

I will also make a video to show you how to setup a reset after my work (in a few hours)

@jean / Alex the issue is in this part from both GetNext...Cast2d actions :

Code: [Select]
// no more colliders?
// check first to avoid errors.

if (nextColliderIndex >= colliderCount)
{
hits = new RaycastHit2D[0]; // This should be : hits = null;
nextColliderIndex = 0;
Fsm.Event(finishedEvent);
return;
}

as OnEnter is looking if hits == null
Title: Re: get next raycast/linecast2d reset
Post by: jeanfabre on April 05, 2018, 04:21:55 AM
Hi,

 Thanks Kurt!

 Bye,

 Jean
Title: Re: get next raycast/linecast2d reset
Post by: djaydino on April 05, 2018, 04:44:30 PM
Hi.
Happy to help :D

Here is the video :