playMaker

Author Topic: Displaying a timer in UI text?  (Read 1970 times)

RGX2015

  • Playmaker Newbie
  • *
  • Posts: 1
Displaying a timer in UI text?
« on: March 04, 2015, 11:43:01 AM »
Hi everyone, I'm new to playmaker and would consider myself a very amateur coder, in this game I'm trying to display a simple timer which keeps track of the total time that the scene's been loaded. I'll attach two screenshots of my FSM, I'm pretty sure I messed something up.

1: http://i.imgur.com/kfHNXuf.png
2: http://i.imgur.com/RVWlier.png

also, playmaker works with 2D Defaults right? When I went to use 2D Box Colliders, I had to switch them to normal Box Colliders for something to work. it seems the 2D UI stuff is a little weird too.

Thanks to anyone who wants to help out!  ;D

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Displaying a timer in UI text?
« Reply #1 on: March 04, 2015, 11:53:09 AM »
You're going to need to convert the float to a string every frame and also display the string every frame. So just click those two boxes and you should be good to go.

TESTLAB_INC

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Displaying a timer in UI text?
« Reply #2 on: March 05, 2015, 11:32:54 AM »
Simple Java Script for a countdown timer, Possible to make it count.
Code: [Select]
#pragma strict

var Timer : float = 10.0;

function Update()
{
Timer -= Time.deltaTime;

if(Timer <= 0)
{
Timer = 0;

// Load the level named "HighScore"
Application.LoadLevel ("HighScore");
//Add here destroy self/Save/Retry
}
}

function OnGUI()
{
GUI.Box(new Rect(10, 10, 50, 20), "" + Timer.ToString("0"));
}

Hope this helped enjoy and goodluck :P
« Last Edit: March 05, 2015, 11:40:45 AM by TESTLAB_INC »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Displaying a timer in UI text?
« Reply #3 on: March 09, 2015, 02:52:03 AM »
Hi,

 It's important you go over all the various samples  from PlayMaker, they will show you all the different technics to use to achieve this.

Then you should study the playlist on the new UI system and how to work with it with PlayMaker.

The script provided by TestLab_inc is indeed something you can all in PlayMaker very easily.

Let me know how ti goes.

Bye,

 Jean