void FirePistol() { var rand = Random.Range(-arcRangeRad, arcRangeRad); // +/- angle from forward var forward = transform.forward; var fireDir = forward + transform.TransformDirection(new Vector3(Mathf.Sin(rand), 0, Mathf.Cos(rand))).normalized; var bullet = Instantiate(BulletPrefab); bullet.transform.forward = fireDir; bullet.transform.eulerAngles = new Vector3(0f, bullet.transform.eulerAngles.y, 0f); bullet.transform.position = firePoint.position; var bulletComp = bullet.GetComponent <Bullet>(); bulletComp.SetSpeed(speed); bulletComp.SetDmg(dmg); bulletComp.SetOwner(1); fireTimeTracker = ReloadTime; camEffects.Shake(0.05f, 0.5f); rigid.AddForce(-forward * kickback, ForceMode.Impulse); rigid.AddForce(-transform.forward * kickback, ForceMode.Impulse); gunShot.Play(); }
private void OnTriggerEnter(Collider other) { if (!other.CompareTag(hitAbleTag) || other.isTrigger) { return; } other.SendMessage("ApplyMeleeDamage", dam); //Damage it var pos = transform.position; other.SendMessage("ApplyKnockback", new Vector4(pos.x, pos.y, pos.z, knockForce), SendMessageOptions.DontRequireReceiver); //apply kickback for this weapon if (camEffects != null) { camEffects.Shake(shakeDir, shakeAmt); camEffects.FreezeFrame(); } }