playMaker

Author Topic: [SOLVED]Timer Problem  (Read 2596 times)

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
[SOLVED]Timer Problem
« on: May 11, 2012, 05:42:29 PM »
Ok so over the past week i've been trying to solve a problem with a timer.

The timer simply counts upwards from level load and then when a trigger is entered the time taken to touch the trigger is shown.

My problem is that i have the same timer set up in two scenes and it functions as it should but any of my new scenes or even projects  it doesn't function, for some weird reason it no longer stops the timer when the trigger is entered.

I have spent a couple of days trying different things with unity+playmaker and ensuring that this problem is not steming from my computer itself as i have tested both the project i'm working with and new projects on another computer and i even today wiped that computers harddrive, started nice and fresh and the timer issue still occurs.

So i've no idea what else to do, any thoughts?
« Last Edit: May 17, 2012, 01:09:29 PM by MrMitch »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: Timer Problem
« Reply #1 on: May 12, 2012, 12:05:29 PM »
Hi,

 First thing I noticed, don't use Built in Events to send Events, instead the System Events should be set as Global Events or transition, this is not a good practice and is counter intuitive.

 So, don't send an event using "TRIGGER ENTER" for example, instead create your own event for this, like "START TIMER" or something.

Now: It could be that you forgot to add the new scenes to the publish settings, that happens to me too sometimes.

Also, don't wipe or reinstall everything when you encounter an issue, post here first :) I never had to reinstall Unity nor playmaker because of any bugs, It's 99.9999% of the case a silly error and wrong set up, or something maybe more serious, but definitly needing to go into such drastic actions :)


Anyway, I have created a working example that I think is what you are willing to achieve.

start the scene, if you don't press any key, the cube will not fall, and there is a 4 seconds time out to let you load the next scene. Each scene is set to load the next, this is defined in the cube prefab, in the "timer" Fsm under the "Level to load" variable ( available in the inspector)

WARNING: make sure you have added the three scenes in the publish settings.
Study how this was done, If you have any questions, let me know.

Bye,

Jean

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Timer Problem
« Reply #2 on: May 12, 2012, 05:57:09 PM »
Thanks for the reply and explaining that to me as i never knew that :)

Sadly i still can't get my timer to work properly even after applying the steps you suggested.

My spare computer was needing wiped anyway so it just gave me the incentive to get on with it :)

I've attached another scene that i quickly set up that uses the same timer setup as my other scenes but i've added what you suggested or at least i think i've added it in correctly, could you please take a look and see if you can find the problem?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: Timer Problem
« Reply #3 on: May 12, 2012, 10:40:04 PM »
Hi,

 the problem is you forgot to create a "float" variable to store the actual time. And PLaymaker does give you red warnings, on the actions themselves, so I create a "time" float variable and plugged that in your "State 1" actions ( get time info and convert float to string)

 Then your scene doens't have anything more so I think this was the problem to get you further.

 One more note:

 When creating Fsm and states, it's always a good practice to force yourself naming them, on a small scene like this one, yes, it's not big deal, but you will quickly start creating more and then when you'll get back to it after some time, it will be almost impossible for you to remember what it was suppose to do and having "state 1" will not help...

So:

name your Fsm components properly ( Avoid the default "FSM")
Name your States properly ( Avoid the default "State x" )
and use the DEscription field of both the Fsm and each State to explain what you are doing or what you want to do)

 This will help you in the long run and give you back the time and effort you invested in forcing yourself to do so , by several order of magnitude!

bye,

 Jean

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Timer Problem
« Reply #4 on: May 13, 2012, 06:36:46 AM »
I have 2 float variables and can't see a use for a 3rd, could you please just built the scene the way it'll work and send me a copy as this is now starting to make me angry as i can't figure anything out ¬.¬
and as for the scene having nothing more that is because i built a seperate scene with just the simple timer so that i could put it into a package and send it
« Last Edit: May 13, 2012, 06:39:05 AM by MrMitch »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: Timer Problem
« Reply #5 on: May 13, 2012, 09:18:57 AM »
Hi,

 Don't panic :) keep up and it will pay off.

the package is attached, I have added a "time" float variable and use it in "Get time info" and "Convert float to string".

you might be confused by the fact that an action by itself does not record or store anything by itself  ( which just gave me an idea to suggest actually :) ), you have to manually tell each actions where to get and set the various informations ( in this case storing and float, and using a float to convert it as a string).

Bye,

 Jean

 

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Timer Problem
« Reply #6 on: May 13, 2012, 10:38:09 AM »
All you've done is change the variable from a global to a none global, it doesn't change anything and then this means i can't read the variable with Float Compare to get my time :S

I would also like add that my original project has two objects that both have an FSM, one controlling the timer and another controlling the trigger enter, end time and GUI, so the global is needed to send over the value.

Thanks for having this patience with me Jean :)
« Last Edit: May 13, 2012, 10:53:35 AM by MrMitch »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3608
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Timer Problem
« Reply #7 on: May 13, 2012, 11:06:44 AM »
I notice you don't have Debug checked. This lets you see the value of your variables at runtime and can really help you figure out what's going on.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: Timer Problem
« Reply #8 on: May 13, 2012, 11:25:42 AM »
Hi,

 ok, I get it....
 
 the package you sent me lost the global variable, that's why I did not have it...

when you send a package  with playmaker and that you have defined and use global events and/or global variables, you need to export the globals and include the created asset in the package, this way when I import the package, I can then get them globals without corrupting existing globals in my project.

So two things now:

1: export properly your scene and include the asset created when you export the playmaker globals ( in the playmaker menu :tools-> export globals.

2: The next problem would be, that I don't really understand where is your problem if your timer is working.

so explain me  again what doesn't work in the package you are going to send me, and what concept you have problem applying back from the example I sent you ( it might a down to earth playmaker feature you don't understand, or a theoritical concept about how to handle timer or scene loading, or triggers, etc)

bye,

 Jean

ps: don't worry, it takes a lot more to start annoying me :) so keep up, we'll get there!

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Timer Problem
« Reply #9 on: May 13, 2012, 12:57:09 PM »
That was something i didn't know, thanks for the info.

I've email you a package of my project, it should have all the files needed, including the global variables :)

Also how do i check my debug?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3608
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Timer Problem
« Reply #10 on: May 13, 2012, 03:36:55 PM »
The Debug check box at the bottom of the State panel, under the actions.

Also Hide Unused will hide optional parameters, which can help when debugging. Just remember to uncheck this when editing so you see all the parameters.

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • View Profile
    • Rage Quit Games - Coming Soon
Re: Timer Problem
« Reply #11 on: May 17, 2012, 01:08:35 PM »
Thanks Alex and a huge thanks to Jean who has helped me solve my problem :)