public static ExplosiveGrenade SpawnGrenade(Vector3 position) { var grenade = new ExplosiveGrenade(GrenadeType.FragGrenade.GetItemType()) { FuseTime = 0.1f, }; grenade.SpawnActive(position); IgnoredGrenades.Add(grenade.Base.gameObject); return(grenade); }
protected void Toss() { bool primaryPressed; primaryPressed = Input.GetButtonDown(useButton); Quaternion fireRotation = Quaternion.LookRotation(transform.forward); Vector3 throwDir = fireRotation * Vector3.forward; if (primaryPressed) { //Debug.Log("Tossed"); Transform t = Instantiate(grenadePrefab).transform; t.transform.position = transform.position; ExplosiveGrenade explosive = t.GetComponent <ExplosiveGrenade>(); explosive.CallStart(); explosive.rb.AddForce(throwDir.normalized * throwForce, ForceMode.Impulse); //explosive.isExploding = true; //explosive.Invoke("Explode", explosionDelay); return; } }