playMaker

Author Topic: get next raycast/linecast2d reset  (Read 4093 times)

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
get next raycast/linecast2d reset
« 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,

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: get next raycast/linecast2d reset
« Reply #1 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

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #2 on: March 28, 2018, 09:12:50 AM »
Thanks so much for looking into this!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: get next raycast/linecast2d reset
« Reply #3 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 :)

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #4 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!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: get next raycast/linecast2d reset
« Reply #5 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)


mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #6 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?


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: get next raycast/linecast2d reset
« Reply #7 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.

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #8 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.

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #9 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.

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #10 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

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 32
Re: get next raycast/linecast2d reset
« Reply #11 on: April 04, 2018, 07:38:44 AM »
Bump to the top...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: get next raycast/linecast2d reset
« Reply #12 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: get next raycast/linecast2d reset
« Reply #13 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
« Last Edit: April 05, 2018, 06:02:34 AM by djaydino »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: get next raycast/linecast2d reset
« Reply #14 on: April 05, 2018, 04:21:55 AM »
Hi,

 Thanks Kurt!

 Bye,

 Jean