Skip to content

Instantly share code, notes, and snippets.

@sanyae2439
Created April 17, 2020 19:01
Show Gist options
  • Save sanyae2439/964ad6f4c0a623fcf5a94ba0a9e6e75e to your computer and use it in GitHub Desktop.
Save sanyae2439/964ad6f4c0a623fcf5a94ba0a9e6e75e to your computer and use it in GitHub Desktop.
public static void SpawnGrenade(Vector3 position, bool isFlash = false, float fusedur = -1, ReferenceHub player = null)
{
if(player == null) player = ReferenceHub.GetHub(PlayerManager.localPlayer);
var gm = player.GetComponent<Grenades.GrenadeManager>();
Grenades.Grenade component = UnityEngine.Object.Instantiate(gm.availableGrenades[isFlash ? (int)GRENADE_ID.FLASH_NADE : (int)GRENADE_ID.FRAG_NADE].grenadeInstance).GetComponent<Grenades.Grenade>();
if(fusedur != -1) component.fuseDuration = fusedur;
component.FullInitData(gm, position, Quaternion.Euler(component.throwStartAngle), Vector3.zero, component.throwAngularVelocity);
NetworkServer.Spawn(component.gameObject);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment