playMaker

Author Topic: timed shooting SOLVED  (Read 2030 times)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
timed shooting SOLVED
« on: November 22, 2013, 06:16:56 AM »
I am having trouble with correct setup of a countdown timer.

My current setup without the countdown timer

start get key down (spacebar) event shoot bullets.

this goes to a bool test were a global can shoot bool is tested

events can shoot and stop shooting

can shoot goes to create the bullet

stop shooting goes to state no shooting (nothing in here) go back to start state.

true = create the bullet (it has FSM to move) go back to start state.

False = go to stop shooting

When the player picks up a gem the global can shoot is flipped from false to true.

So gem picked up global value true spacebar pressed you can shoot bullets, bullet created for every spacebar press.

I want to limit the shooting to within a ten second time limit.

You can shoot for ten seconds, when time up no more shooting and reset the timer back to ten seconds.

If you are shooting and pickup another gem add more time to the shooting timer.

The FSM that currently handles the shooting is on the player this object is not a prefab and is always on screen.

I keep running into issues with the timer and the spacebar being pressed.

I attached the screenshot of the current FSM

Could someone please help


« Last Edit: November 25, 2013, 07:13:11 AM by colpolstudios »

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: timed shooting
« Reply #1 on: November 22, 2013, 10:55:01 AM »
update: I put the countdown timer onto an empty game object.

start add 8 to timer

custom event global

start timer (this event is called from the gem)

state (timer started) set bool value I have a local bool set to true

Global can shoot set value to local value True.

float add -1 per sec and every frame to time

float compare time to zero

equal or less than event stop shooting

Stop shooting set Global can shoot set value to local value false.

All seems to work fine, but curious what happens if I pickup two gems

I think the start event should add 8 to any existing time on the countdown.

I just have not been able to collect two gems within the time limit to test the theory.

possibly someone with more experience than myself could answer.





colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: timed shooting
« Reply #2 on: November 24, 2013, 07:10:27 PM »
I have come to see errors with this setup,

Due to the global start timer state I need to add any additional pickups within here I think?

The start state only covers the first time I pickup and not any more.

Once I have picked up I will always be in the global start timer state.

Possibly someone could jump in and help a little.

I am close but could do with a little help.

edit: I was overthinking simply moved the add 8 to timer into the global start timer and removed this action from the start state.



« Last Edit: November 25, 2013, 07:12:39 AM by colpolstudios »