- Home /
eating candy, spitting it out.
this is my pick up item script. i pick up candy. wait, there's more.
#pragma strict
private var score : int = 0;
var guiScore : GUIText;
function Start () {
guiScore.text = "Sweets: 0";
}
function OnCollisionEnter(col : Collision){
if(col.collider.name == "Candy"){
Destroy(col.gameObject);
score += 10;
guiScore.text = "Sweets: " + score;
print("collide with Candy");
}
}
i have a character that spits chewed candy. the thing is... he can spit an unlimited amount of candy as of now. i wanted him to have to pick up the candy before he spit it out... much like ammo...or...exactly like ammo. is there a way to disable the shoot function until he eats at least one candy? one candy will give him 10 ammo? my script above works well and displays a gui that indicates the amount picked up. now if only i could have that number decrease by one as he spits. i know it sounds crazy. i dont know where to start... otherwise i would be fixing this problem instead of desperation typing on a message board. any ideas? any at all? i am stumped. if you need my bullet code or spawn code let me know. all of them work perfectly. this little thing would give the collecting of candy much needed importance! thanks again. -matt
on a side note... this should be fairly simple... seeing as how i do not have different ammo types and guns and such. i have tried writing a few scripts but am embarrassed to show them. they are awful and don't work. it's almost ridiculous how new i am to this whole thing. you would think i wrote them with crayon.
Answer by EHogger · Jul 04, 2013 at 09:49 AM
So "score" in your script is actually ammo?
in your shoot function, just do something like:
if (score > 0){
Shoot();
score -= 1;
}
Your answer
Follow this Question
Related Questions
Clones of enemies will not shoot 0 Answers
pickup counter and timer help 0 Answers
Pick Up Script "overflowing" 4 Answers
How can I keep my ammo count going over the cap? 1 Answer
Auto shooting script. 1 Answer