Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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,
-
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)
-
Thanks so much for looking into this!
-
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 :)
-
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!
-
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)
-
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?
-
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.
-
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.
-
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.
-
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
-
Bump to the top...
-
Hi,
can you send me a package of this scene, and I'll check what's wrong. Thanks :)
Bye,
Jean
-
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 :
// 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
-
Hi,
Thanks Kurt!
Bye,
Jean
-
Hi.
Happy to help :D
Here is the video :