public override void Execute(Character owner, float baseDamage, Vector3 intendedDirection, Vector3 origin) { Vector3 dir = intendedDirection + Vector3.up * upwardsForce; //account for gravity GameObject proj = Instantiate <GameObject>(projectile, origin, Quaternion.identity); Rigidbody rb = proj.GetComponent <Rigidbody>(); RigidbodyProjectileOnHit onHit = proj.GetComponent <RigidbodyProjectileOnHit>(); if (rb == null) { Debug.LogWarning("RigidbodyBallistics projectiles must have a rigidbody component"); return; } if (onHit == null) { Debug.LogWarning("RigidbodyBallistics projectiles must have a RigidbodyProjectileOnHit component"); return; } onHit.UpdateOnHitSettings(owner, baseDamage, ignoreLayers, persistTime); rb.velocity = dir.normalized * projectileSpeed; proj.transform.parent = container.transform; }
public override void Execute(Character owner, Weapon weapon, Vector3 intendedDirection) { Vector3 origin = weapon.runtime.weaponTip.position; Vector3 dir = intendedDirection; GameObject proj = Instantiate <GameObject>(projectile, origin, Quaternion.identity); Rigidbody rb = proj.GetComponent <Rigidbody>(); RigidbodyProjectileOnHit onHit = proj.GetComponent <RigidbodyProjectileOnHit>(); if (rb == null) { Debug.LogWarning("RigidbodyBallistics projectiles must have a rigidbody component"); return; } if (onHit == null) { Debug.LogWarning("RigidbodyBallistics projectiles must have a RigidbodyProjectileOnHit component"); return; } onHit.UpdateOnHitSettings(owner, weapon, ignoreLayers, persistTime); rb.velocity = dir.normalized * projectileSpeed; proj.transform.parent = container.transform; }