- Home /
Question by
shithappens72 · Sep 24, 2012 at 01:20 AM ·
limitwords
How do you Limit objects picked up?
i need some help i am trying to make a game for the special ed class. my current code is:
var wordCollect : AudioClip;
function OnTriggerEnter(collisionInfo : Collider)
{
if(collisionInfo.gameObject.tag =="word")
{
WordCollect.charge++;
audio.PlayOneShot(batteryCollect);
Destroy(collisionInfo.gameObject);
}
}
@script RequireComponent(AudioSource)
Comment
Read this yourself:
"i need some help i am trying to make a game for the special ed class. my current code is:"
And now tell us what you want.
What is special ed? What do you mean by limit pickup? Do you mean when you reached a certain amount you should not be able to pickup more?
Answer by Bunny83 · Sep 24, 2012 at 01:26 AM
Maybe you want something like this:
var wordCollect : AudioClip;
var maxWords : int; // set in the inspector.
function OnTriggerEnter(collisionInfo : Collider)
{
if(collisionInfo.gameObject.tag =="word" && WordCollect.charge < maxWords)
{
WordCollect.charge++;
audio.PlayOneShot(batteryCollect);
Destroy(collisionInfo.gameObject);
}
}
@script RequireComponent(AudioSource)
Your answer
Follow this Question
Related Questions
limiting rotation to solid angle 5 Answers
Field of view, using raycasting 5 Answers
How to limit bullets in screen like old NES game 4 Answers
How do you limit velocity on a rigid body in only one direction? 1 Answer
Having a fuel limit 1 Answer