So I have code that used to work with OnTriggerEnter to cause damage to other players. Now I put the trigger off my projectile and I want to use it to cause damage to people as well as hit walls and break them down, thus the no trigger.
Now I have the ability to collide with walls and trees to make them fall. However, I lost the ability to cause damage to players. Here is my code, it just doesn't work. I tried a bunch of different things and now I have no clue.
// Inside the Player class
If I disable the networkView.isMine then neither player gets hit, or more weird things happen.
asked Feb 06, 2012 at 06:09 AM
take a look at the collider matrix. It shows you exactly when OnTrigger and OnCollision events get fired, and when they don't. You will most likely have to rearrange how your collisions and triggers work in combination with their components. Scroll to the bottom of this link.
answered Feb 06, 2012 at 09:46 PM
I think your network stuff was wonky, even before the changes. They are just showing it up.
SendMessage doesn't(?) do anything over the Network. If Steve shoots Alice, then Alice's copy of the bullet echo's Steve's "real" copy (you're using Network.Instantiate?) The real bullet on Steve's machine hits Alice first, due to lag, and turns itself inactive. It does nothing to the local copy of Alice, because of the isMine. Meanwhile, the bullet on Alice's machine, which was about to also hit Alice, freezes up -- it copies the (now inactive) real bullet.
I believe the "Unity recommended" way is to have the isMine check in the bullet. This solves the problem of one bullet thinking it hit, but the copy just barely missing. The "real" bullet sends an RPC("getHit") to all copies of what it hit, and another RPC (or Network.Destroy) to all of its copies.
answered Feb 07, 2012 at 03:44 AM