public override void Launch(Rigidbody projectile, ProjectileInfo projectileInfo) { projectile.useGravity = false; var direction = (projectileInfo.TargetPosition - projectileInfo.StartPosition).normalized; projectile.transform.rotation = Quaternion.LookRotation(direction); projectile.velocity = direction * StartSpeed; }
public override void Launch(Rigidbody projectile, ProjectileInfo projectileInfo) { projectile.useGravity = true; if (!TryGetStartVelocity(projectileInfo.StartPosition, projectileInfo.TargetPosition, StartAngle, out var startVelocity)) { startVelocity = StartSpeed * startVelocity.normalized; } projectile.velocity = startVelocity; }
public bool Launch(Launcher launcher, ProjectileInfo projectileInfo) { if (!launcher.CanShoot) { return(false); } var projectile = _projectilePools[launcher.Config].GetObject(); projectile.Init(projectileInfo); projectile.Hit += OnHit; projectile.transform.position = launcher.LaunchPoint.position; projectile.transform.rotation = launcher.LaunchPoint.rotation; projectile.gameObject.SetActive(true); projectileInfo.StartPosition = launcher.LaunchPoint.position; launcher.Launch(projectile.Rigidbody, projectileInfo); return(true); }
public void Launch(Rigidbody projectile, ProjectileInfo projectileInfo) { Config.Launch(projectile, projectileInfo); _lastShotTime = Time.time; }
public abstract void Launch(Rigidbody projectile, ProjectileInfo projectileInfo);
public void Init(ProjectileInfo projectileInfo) { Info = projectileInfo; }