I’ve got a networked multiplayer game going using the M2H examples as the starting point. Everything is working fine except that I have to use instantiated projectiles instead of raycasting (they are slow-moving missiles and things), so I’m trying to figure out how to determine which player fired the projectile that hits another player.
I’ve tried setting variables on scripts on the projectiles and everything else I can think of, but nothing seems to work. The method that’s gotten me the closest is to have the player that fires the projectile rename it. Then the player it hits can use OnCollisionEnter(hit : Collision) to read the name and do the appropriate calculations.
I currently have this in a script on the player firing the projectile:
var projectile : Transform;
function FireMissile () {
var missile = Network.Instantiate(projectile, launcher.position, launcher.rotation, 0);
missile.name = "myFancyMissile";
}
Unfortunately, this works great, but only for the player that is also the server. None of the other players’ missile names change and I can’t figure out why. I’ve got a network view and so on on the prefab, and they work just fine otherwise. They just don’t get the name change.
I’m not tied to this approach. It’s just the one that’s gotten me the closest, so I’m open to other suggestions.