I have created physical bullets and on collision i need them to acquire someones health then modify it How to aquire it and modify it in networked state?
The question has been closed Jun 27 '12 at 09:59 AM by yeoldesnake 1 for the following reason:
I realize this may not be an "answer", but how, specifically are you doing your bullets? Are they objects with rigidbodies that actually travel through the world at really fast speeds? If so, I've got some bad news... your bullets won't be very accurate. Let me explain.
When each frame is computed and drawn by the system, the physics subsystem calculates the new positions of all the objects that were "acted upon" by some force, and then it checks for collisions. But if your bullets are really really tiny, and they're moving really really fast, here's what's going to happen:
FRAME 1 ---------------------------- +--+ | | . |PL| | | | | +--+ FRAME 2 ---------------------------- +--+ | | |PL| . | | | | +--+
The dot is the bullet, and the box is your player (or whatever bullets get shot by). It's going so fast, that it literally skips over the player and never collides with it, because the physics calculations put it before, and then immediately after the player. There is no "in between", this happens in a few milliseconds, and the engine doesn't check to see if it might have collided with anything between those two points in space.
The solution? Use Raycasts. They are instantaneous lines that "hit" things at a specific point in space. Think of it like an instantaneous laser beam that collides with colliders in the world. There are various functions to drawing raycast lines in the world, and getting the data from whatever you hit, and so on. Look up "Physics.Raycast" in the Script Reference, it should tell you all you need to know about them.
answered Mar 22 '10 at 05:39 AM