playMaker

Author Topic: Vary rate of raycast/draw line for laser weapons.[SOLVED]  (Read 822 times)

curb47

  • Sr. Member
  • ****
  • Posts: 256
Vary rate of raycast/draw line for laser weapons.[SOLVED]
« on: July 30, 2020, 02:46:43 PM »
Hello,

Hope you're all well.

I need some more help with my spaceship lasers! I'd like to vary the rate at which the lasers fire, ie the raycast/draw line combo. I want the player to be able to power-up and increase the rate of fire/power of the lasers as they progress through the game.

Now, I thought it would be really simple, by just adjusting the Repeat Interval in the Raycast (I'm using Raycast 2 from the ecosystem), but that seems to have no effect.

I've also tried setting the FSM as an Action Sequence and having a Wait action at the end, but the action sequence gets stuck on the Raycast action and doesn't move down the list of actions.

I don't want to start over-complicating my FSM, and I'm sure there must be a simple solution.

Any help is, as always, greatly appreciated.

All the best.

J. 
« Last Edit: August 01, 2020, 01:28:31 AM by curb47 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Vary rate of raycast/draw line for laser weapons.
« Reply #1 on: July 30, 2020, 05:57:41 PM »
Hi.
If you want to use action sequence you should set the repeat interval to 0 on the raycast.
This way it will cast only once.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: Vary rate of raycast/draw line for laser weapons.
« Reply #2 on: July 31, 2020, 01:53:44 AM »
Hi Dino,

Great to hear from you, I was hoping you'd comment on this one.

I've changed the Repeat Interval to Zero, and it kinda worked, the Action Sequence got stuck on another action.

I would really like to understand what's going on here, as you mentioned the Action Sequence in your previous answer to my other question (I think it was you, it might have been Jean) and I ended up not implementing it as I was happy with the result of the lasers shooting at the time.

However, now I'm ironing out the finer details and I need to have full control over the rate-of-fire of the lasers, so I need to return to this FSM.

If you don't mind, could you look over the FSM for me, and see where I'm going wrong? If I want to utilise Action Sequence to gain control over the rate-of-fire by simply changing the Wait action time at the end, how do I get it to flow?

Here's some screen grabs on the FSM...













You can see in the screen grabs, all the actions are enabled, however, when I was running the game, I had to use trial and error/process of elimination and disable some actions to get any result.

As a starting point I speculated that Every Frame needed to be UNchecked for any action that had it. Correct?

On a side note, my State 2 is filled with lots of actions, is this normal? Like, is there a logical limit to the number of actions that any State should contain?

Thank you so much. I'm sorry to be taking up so much of your time.





« Last Edit: July 31, 2020, 02:28:43 AM by curb47 »

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: Vary rate of raycast/draw line for laser weapons.
« Reply #3 on: July 31, 2020, 02:34:22 AM »
One initial problem with the Action Sequence, was having the Get Key Up action enabled.

The logic got stuck here, right at the beginning, as I guess the Action Sequence is waiting for the the key 'M' to be released before it can move on. The problem is, when 'M' is released, it sends to event 'finished' and it returns to the 'Listening' state at the start.

This opened up another can of worms in my head... how do I Get Key Up in the Action Sequence, in order to register the player has stopped firing the lasers, if the sequence can't move past the Get Key Up action?

My brain is going down a wormhole of infinite loops... it hurts.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: Vary rate of raycast/draw line for laser weapons.[SOLVED]
« Reply #4 on: August 01, 2020, 01:34:41 AM »
Yay! I've done it!

Actually, it was pretty clear after Dino suggested setting the Repeat Interval to Zero.

All I had to do was remove the Get Key Down, and set up a separate State after the Fire Lasers Action Sequence State with a Get Key. The only addition to the Action Sequence State is a Send Event to trigger the audio of the lasers.

I now have a Wait action at the end of the Fire Lasers Action Sequence that I can simply alter the duration to change the rate of fire.