- Home /
How to go about purchasing objects with player score/points?
Point me in the right direction? Thanks!
A little more explanation: Trying to set up my game to where, with points/score earned, the player can use this as currency to purchase a displayed item, not in a menu, they just walk up to it, press a certain button, and wallah!
Answer by smirlianos · Dec 24, 2012 at 05:55 PM
If I were you, I would make a script attached to the item that counts the money/points the player has with a variable and the price of the object, like this. If the player touches the item and the money he ha is more or equal to the price, he will buy it!
var points : int;
var price : int;
function OnTriggerStay(other : Collider) {
if(Input.GetKeyDown("p") && points >= price)
{
//put stuff when he purchase it
}
}
I cant exactly do it like you say, because I will hace several of these triggers. So I cant really have my score counter on them all. Trying to figure out the sendmessage function. Ive looked at unity books but find they are pretty basic when it comes to program$$anonymous$$g.
try having a "manager" GameObject with a script that counts your points then
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Score Keeper / Kill Counter Help 1 Answer
Footsteps Java Script Problems 0 Answers
java script help 1 Answer
Displaying Score on screen 2 Answers