public void OnUpdate(IBulletController controller) { if (axis == Vector3.zero) { BulletStormLogger.LogErrorOnce($"{controller}: In Around axis module, axis can't be zero!"); return; } Vector3 axisInWorld; switch (space) { case Space.World: axisInWorld = axis; break; case Space.Self: axisInWorld = controller.Rotation * axis; break; default: throw new ArgumentOutOfRangeException(); } var angle = anglePerSecond * Time.deltaTime; controller.ChangeParam(param => { param.rotation = Quaternion.AngleAxis(angle, axisInWorld) * param.rotation; return(param); }); }
/// <summary> /// Call this on every update. /// </summary> /// <param name="bullet"></param> public void OnUpdate(IBulletController bullet) { if (!target.Check()) { BulletStormLogger.LogWarningOnce($"Can not find {target}"); return; } var targetPosition = target.AsTransform.position; var rate = tracingRate * Time.deltaTime; var enableCurve = enableRateCurve; var curve = tracingRateCurve; bullet.ChangeParam(param => { var direction = param.rotation * Vector3.forward; var aimDirection = targetPosition - param.position; var axis = Vector3.Cross(direction, aimDirection); var dAngle = enableCurve ? curve.Evaluate(Vector3.Angle(direction, aimDirection)) * rate : rate; if (dAngle < 0) { dAngle = 0; } param.rotation = Quaternion.AngleAxis(dAngle, axis) * param.rotation; return(param); }); }
public void OnUpdate(IBulletController controller) { var dEuler = new Vector3(-deflection.y * Time.deltaTime, deflection.x * Time.deltaTime); var rotation = Quaternion.Euler(dEuler); controller.ChangeParam(param => { param.rotation = rotation * param.rotation; return(param); }); }
public IEnumerator Execute(IBulletController controller, Transform emitter) { var startTime = Time.time; while (Time.time - startTime < duration) { var deltaTime = Time.deltaTime; controller.ChangeVelocity((position, velocity) => Quaternion.Euler(angularVelocity * deltaTime) * velocity); yield return(null); } }
public IEnumerator Execute(IBulletController controller, Transform emitter) { var startTime = Time.time; while (Time.time - startTime < duration) { var deltaTime = Time.deltaTime; controller.ChangeVelocity((position, velocity) => velocity + (customDirection ? accelerationVector * deltaTime : velocity.normalized * (acceleration * deltaTime))); yield return(null); } }
void IWeaponController.DoShoot() { if (!CanShoot) { return; } LastShootTime = DateTime.Now; Vector3 direction = _bulletTransformProvider.BulletSpawnDirection; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward); IBulletController bullet = _bulletFactory.Create(_bulletPrefab, _bulletTransformProvider.BulletSpawnPosition, rotation); bullet.StartShoot(_bulletTransformProvider.BulletSpawnDirection); }
public void OnUpdate(IBulletController bullet) { if (!enabled || !target) { return; } var deltaTime = Time.deltaTime; var targetPosition = target.AsTransform.position; var ratio = this.tracingRate; bullet.ChangeVelocity((position, velocity) => Vector3.RotateTowards( velocity, targetPosition - position, ratio * deltaTime * Mathf.Deg2Rad, 0)); }
public void OnUpdate(IBulletController controller) { var deltaTime = Time.deltaTime; var acc = acceleration; var min = minSpeed; var max = maxSpeed; controller.ChangeParam(param => { var speed = param.speed + acc * deltaTime; if (acc < 0 && speed < min) { speed = min; } else if (acc > 0 && speed > max) { speed = max; } param.speed = speed; return(param); }); }