- Home /
Passing a gameobject through two methods
I am trying to pass the WeaponGraphic through the Instantiate method in a ClientRpc Call. However I need first to declare it to the server. So the weapon graphic need to be passed over through two methods. When I try this I get the following error:
ArgumentException: The Object you want to instantiate is null.
Here is my code:
public void BuyAk(){
CmdSpawnThatShitWeapon(0, _weapon.Ak.WeaponGfx);
}
[Command]
void CmdSpawnThatShitWeapon(int index, GameObject gfx1)
{
RpcSpawnThatShitWeapon(index,gfx1);
}
[ClientRpc]
void RpcSpawnThatShitWeapon(int index, GameObject gfx)
{
_weaponIns[index] = Instantiate(gfx, _weapon.WeaponHolder.position, _weapon.WeaponHolder.rotation);
}
For debbuging: If I replace gfx normally with _weapon.Ak.WeaponGfx the code work fine and no error is thrown. However I am using other weapons and I want to pass other graphics. So how do I proceed? Thank you for helping me.
Your answer
Follow this Question
Related Questions
ArgumentException: The Object you want to instantiate is null. 1 Answer
Best way to pass variables between instantiated/colliding objects? 1 Answer
Attach a value to an instantiate object and call it in the class of this object 0 Answers
Calling a variable 2 Answers
Only change a variable on the instaniated object not the prefab. 0 Answers