- Home /
ArgumentException: The Object you want to instantiate is null.
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.
CmdSpawnThatShitWeapon(0, _weapon.Ak.WeaponGfx);
Is the WeaponGfx properly assigned to?
Answer by hectorux · Dec 09, 2018 at 04:14 PM
do you have well reference your _weapon or your weapon.Ak? If one of those isnt referenced then will throw that error