- Home /
How to have it so if I push an object into a cirten object, the pushed object but not me will be destoryed?
Hello. I basically want to have an object that you push some other object into it, the object that was pushed into it will be removed form the game. I am a real noob to scripting, and it never seems to work out for me!!!!! I would really appreciate it if someone would give me a script that did that. P.S. My characters can't be destroyed too, only the dummy objects. Thanks! :P
Comment
Answer by Jesus_Freak · Nov 18, 2010 at 09:23 PM
ok... not very clear, but i'll try to answer. it sounds like you have Player, BoxA and BoxB.
it sounds like you want when BoxA is pushed into and touches / collides with BoxB, BoxA gets destroyed, right?
here's a script for that, just attach it to BoxB. :
function OnTriggerEnter (hit : Collider)
{
if(hit.gameObject.tag == "BoxA")
{
Destroy(hit.gameObject);
}
}