- Home /
Collecting and add points
Hello everyone, to get it out there I am a complete noob and I need help. I am in a video game design class and the biggest problem that I am having is the js.
Right now I am trying to make a level for class that has a ball that rolls through the level collecting objects. Once all of the objects are collected you are supposed to go to the "winScene" and if you don't do it in time you go to "loseScene".
Right now when I run the game I find the problem that the object I have set as a trigger falls through the floor and then the game comes directly to the "loseScene"
Here are my scripts that I am using right now. I realize they are probably not right but I really need to learn and want to learn.
Collect.js
var score = 0; var gameObject : Transform;
function OnTriggerEnter () { if (hit.gameObject.tag == "collectacube"){ CollectionManager.scoreText ++ ; Destroy(gameObject); } }
CollectionManager.js
static var CollectedCount : int;
var scoreText : GUIText; var completionTime : float = 55; var startTime : float;
function Start(){ startTime = Time.time; }
function Update () { var timeElapsed = Time.time - startTime;
if(timeElapsed > completionTime){ Application.LoadLevel("loseScene"); }
if(timeElapsed < completionTime && CollectedCount == 1){ Application.LoadLevel("winScene"); }
//Debug.Log("Collected" + Collected Count);
scoreText.text = ("Collected" + CollectedCount);
}
The collection manager script was written by the professor with the class as a group participation. From what I understood I needed the collect script to get the score and the manager was going to get the score or something from the collect script and do what it had to do.
What am I missing? Thanks for the help.
Answer by Myth · Feb 02, 2011 at 11:23 PM
the object I have set as a trigger falls through the floor
- have you turned off affected by gravity under the rigid body component?
I can't remember what we did exactly I do remember the fact that my object was parented wrong and had a lot of rigid bodies. This issue has been resolved with my professor for now. Thanks for the help.
Your answer
Follow this Question
Related Questions
Game Character manager 0 Answers
how to make a currency system 0 Answers
Help With Score Controller - Can You Only Have One? 1 Answer