- Home /
Problem getting prefabs to spwan correctly from within RPC
I have no problem spawning rockets from my ship without using RPC's.
i'm new to using RPC's . this is how i instantiated my rockets from within an RPC
public Transform bigbabgprefab;
void FireWeapons ()
{
if ( Input.GetKeyDown("x"))
{
networkView.RPC("FireRocketAcrossNetwork",RPCMode.All);
}
}
[RPC]
void FireRocketAcrossNetwork(string originatorName , string name)
{
//access the collision script of the prefab projectile
// and supply the players name and teamname
Transform gameobj3 =(Transform) Instantiate(bigbabgprefab,transform.Find("bigbangspawnpoint").transform.position,Quaternion.identity)as Transform;
gameobj3.rigidbody.AddForce(transform.forward *16000);
}
whenever the rocket is fired it moves haphazardly , in a mostly zig-zag way . i'm 100% sure my coding here is the problem but i have limited knowledge in this areas . what aspect of this snippet could be the problem ? thanks in advance for any answers .
Try calling AddForce from a script inside the rocket itself, preferrably in Start();
Okay, one thing I see, which may(probably doesn't) have nothing to do with your problem, but...
Transform gameobj3 = (Transform) Instantiate(bigbabgprefab,transform.Find("bigbangspawnpoint").transform.position,Quaternion.identity)as Transform;
You're defining this as a Transform three times. Why?
I have decided to use my original code
Transform bangblast = (Transform) Network.Instantiate (bigbabgprefab,transform.Find("bigbangspawnpoint").transform.position,Quaternion.identity,0);
it should work
thanks guys . I saw the problem . tw 1st3d you are absolutely correct. i must now have been paying attention
Your answer

Follow this Question
Related Questions
RPC - Transform not Supported? 1 Answer
Spawn help? 0 Answers
Load level and transform 1 Answer
Mutliplayer SetActive(true) 0 Answers
Wont let me instantiate gameobject when i destroy it? 0 Answers