- Home /
IgnoreCollision on a Network Instantiated Object
I want to spawn a projectile in a network game, but I don't want it to explode immediately. I was trying to use IgnoreCollision, but I realized that after calling Network.Instantiate, only the originating client will process the IgnoreCollision call.
Is there a network safe way to do this or do I just need to instantiate the projectile far enough away from the originating object?
GameObject thisProj = Network.Instantiate (Projectile, projLocation, projRotation, 0) as GameObject;
Physics.IgnoreCollision(thisProj.collider, Shooter.collider);
Why not just use Invoke or a coroutine and a waitforseconds approach?
Answer by jashan · Aug 13, 2010 at 07:40 AM
You'd have to put your call to Physics.IgnoreCollision into
MonoBehaviour.OnNetworkInstantiate
That should do the trick. The call the way you wrote it only has an effect on local objects because Physics is not automatically "network aware".
Sure, but the trick is passing Shooter to OnNetworkInstantiate somehow. Any ideas?
Answer by LoganBarnett · Jun 17, 2011 at 02:35 AM
In your projectile's Start() set collider.isTrigger = true if the client is executing (Network.isClient). This will allow the server to authoritatively handle collisions, as it should (:
Your answer
Follow this Question
Related Questions
How can I instantiate an Orthello prototype with the Network class? 1 Answer
Network.Instantiate spawns multiple objects 2 Answers
Game works when i use "build and run" and in the game tab, but not when i build it as an EXE 0 Answers
Network.instantiate for specified clients? 1 Answer
How to instantiate a prefab with a shared Network Identity? 1 Answer