hi, does anyone have any tips for me on how to have my FPS character pick up objects and add it to a score? I have tried to use the 3D platform tutorial scripts, but i really dont know enough about scripting to modify the tutorial scripts.
Yes the scriptName is the name of the script you have your score code on. You will have to make the var static to be read/altered from the items script, thats one way a script talks to another.
If you’re using the GUI system (which you can read about here), you would just submit the score as content for whatever type of control you’re using (e.g. Label). If you have the score in numerical form, you can use ToString() (or the UnityScript equivalent - maybe the case is different?) to convert the score to string form.
thank you for reply, about the having score and time, i guess i didnt think it through at first, but as this will be gathering objects which will give points, and do this in the least amount of time, i want the time to deduct from the score every 1 minute or something like that.
It looks like you have a debug message in there that tells you when a ‘pick up’ item has been collided with. When the score goes up by two, does that message get output twice? Are you sure you don’t have two items right on top of each other?
I answered that question earlier in the thread, here:
You could probably also work it into your current code, e.g. (guessing at the UnityScript syntax here):
var startTime;
var oldMinutes = -1;
function Awake() {
startTime = Time.time;
}
function Update () {
var Time = Time.time - startTime;
var minutes : int = Mathf.Floor(Time / 60);
var seconds : int = Time % 60;
var fraction : int = (Time * 100) % 100;
guiText.text = String.Format ("{0:00}:{1:00}:{2:00}", minutes, seconds, fraction);
if (minutes != oldMinutes) {
...decrease score here...
}
oldMinutes = minutes;
}
this just removes game objects when the character collides with them. And the last code just strings “score goes here” into my gui text box. All works, but i want to have the gui text add points every time the character collides with a object.
Actually what i aim for as well, in addition to this, is to have my timer deduct points every minute or so.
Sorry im just not good at scripting at all. Can anyone help me with this? Would be very helpfull and appreciated.
Thanks a lot! Works good. Only thing i dont understand is that it jumps straight from 1 points to 3 points, and then continues normal after that. Any idea what causes this?
And im sorry to ask this, but do you know how to deduct points every minute, or something like that?
I already have the time working:
var startTime;
function Awake() {
startTime = Time.time;
}
function Update () {
var Time = Time.time - startTime;
var minutes : int = Mathf.Floor(Time / 60);
var seconds : int = Time % 60;
var fraction : int = (Time * 100) % 100;
guiText.text = String.Format ("{0:00}:{1:00}:{2:00}", minutes, seconds, fraction);
}
It looks like you have a debug message in there that tells you when a ‘pick up’ item has been collided with. When the score goes up by two, does that message get output twice? Are you sure you don’t have two items right on top of each other?
I answered that question earlier in the thread, here:
You could probably also work it into your current code, e.g. (guessing at the UnityScript syntax here):
var startTime;
var oldMinutes = 0;
function Awake() {
startTime = Time.time;
}
function Update () {
var Time = Time.time - startTime;
var minutes : int = Mathf.Floor(Time / 60);
var seconds : int = Time % 60;
var fraction : int = (Time * 100) % 100;
guiText.text = String.Format ("{0:00}:{1:00}:{2:00}", minutes, seconds, fraction);
if (minutes != oldMinutes) {
...decrease score here...
}
oldMinutes = minutes;
}