- Home /
Unity Engine issue...
I made myself several scripts, one controls a timer, another is an spawn controller that uses an array. My problem is that yesterday all of my scripts were working fine but when I logged on today the timer won't count down and the spawn controller won't spawn clones anymore. What could be the issue?
edit
private var startTime;
private var restSeconds : int;
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
var Clock : GUIText;
var newSkin : GUISkin;
var countDownSeconds : int;
function Awake()
{
startTime = Time.time;
}
function OnGUI ()
{
//make sure that your time is based on when this script was first called
//instead of when your game started
var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
//display messages or whatever here -->do stuff based on your timer
if (restSeconds == 10) {
}
if (restSeconds == 0) {
Time.timeScale = 0.0;
GUI.Box(Rect(20, 15, 1040, 580), "");
if(GUI.Button(Rect(60, 300, 450, 200), "Quit")) {
Application.Quit();
}
if(GUI.Button(Rect(560, 300, 450, 200), "Replay Level")) {
Application.LoadLevel("Level_1");
}
}
//display the timer
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
Clock.text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
}
//Total Score Script
var ScoreBoard: GUIText;
static var Points = 0;
private var Total: int = 0;
var topscore : int;
function Update ()
{
ScoreBoard.text = ("Score: ") + Points;
if (Points >= topscore){
Application.LoadLevel("Level_2");
Points = 0;
}
}
and here it the spawn script:
var arr : Array;
var game_cube : Rigidbody;
var cube_count = 0;
var walker0 : Transform;
var walker1 : Transform;
var walker2 : Transform;
var walker3 : Transform;
function Start ()
{
InvokeRepeating("LaunchProjectile", 2, 1);
arr = new Array();
arr.Push(walker0);
arr.Push(walker1);
arr.Push(walker2);
arr.Push(walker3);
}
function LaunchProjectile ()
{
var randomPick : int = Random.Range(0,3);
var spoint : Transform = arr[randomPick];
var instance = Instantiate(game_cube, spoint.position, spoint.rotation);
instance.velocity = Vector3.zero;
cube_count++;
}
the most confusing thing is that I have gravity check box turned on and the object with the AI clones don't fall.
Answer by Dudesaydude · Oct 12, 2011 at 08:33 AM
This might not be useful but maybe you can check in inspector panel if you´ve set you´re variables? Sorry if this doesn´t help. I´m nowhere near professional but I would love to help someone with the little knowledge I have. God I hope this is of some use to you.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
random spawn locations.... 2 Answers
Instantiate 1 at a time at each transform in array 1 Answer
Multiple spawn points using Array... 1 Answer
Random textures... 1 Answer