Well, I have been scripting for a few days now and everything has gone well so far, but I just now came to my first stop and I need some help.
I have hidden a few objects around the map, and when the player steps into it’s box collider, I need it to destroy the original hidden object. I use javascript, so preferably if someone can show me how to do it once, then I can continue by myself. I tried searching on the forums but nothing really worked.
This seems to turn the whole map grey as soon as I enter the hidden item’s trigger. It may be deleting the whole map or my character. But I just need it to delete the object itself. Is there anyway to make it not delete the player?
Edit: If there is no way, I can find a work around… But it would be alot better if I could get it to only delete the object.
There is always a way, look at the snippets of code and analyst what they actually represent. If you have this section placed on object “door” then when you enter the trigger collider of the door, it will destroy the whole gameObject which the script is attached to.
If you wanted to destroy another object you can simple define a variable by going…
Var objectToDestroy : GameObject;
Function OnTriggerEnter(other : Collider){
Destroy(objectToDestroy);
}
So basically you need this script on your hidden objects.