void AIShootAtPlayer() { if (Time.timeScale > 0 && playerInRange) { aimDirection = Vector3.Normalize(targetPlayer.transform.position - launcher.getWorldSpawnLocation()); Quaternion targetRotation = Quaternion.LookRotation(targetPlayer.transform.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotationSpeedAI * Time.deltaTime); RaycastHit raycastHit; if (Physics.Raycast(launcher.getWorldSpawnLocation(), distanceFromPlayer + new Vector3(0, aimOffsetHeight, 0), out raycastHit) && raycastHit.transform.tag == "Player" && Time.time > nextShot) { nextShot = Time.time + shootSpeed; launcher.Launch(aimDirection + new Vector3(0, aimOffsetHeight, 0)); } } }
private void OnSceneGUI() { ProjectileLauncher projectileLauncher = target as ProjectileLauncher; Transform transform = projectileLauncher.transform; using (var cc = new EditorGUI.ChangeCheckScope()) { Vector3 newOffset = transform.InverseTransformPoint( Handles.PositionHandle( transform.TransformPoint(projectileLauncher.spawnLocation), transform.rotation ) ); if (cc.changed) { Undo.RecordObject(projectileLauncher, "Spawn Change"); projectileLauncher.spawnLocation = newOffset; } } Handles.BeginGUI(); GUILayoutOption[] layoutOptions = { GUILayout.Width(64), GUILayout.Height(18) }; if (GUILayout.Button("Launch", layoutOptions)) { projectileLauncher.Launch(transform.forward); } Handles.EndGUI(); }
private void Update() { if (Time.time > cooldownExpires && Random.value < data.fireChance * Time.deltaTime) { GameObject projectile = ProjectileLauncher.Launch(data.projectile, data.fireSFX, transform); projectile.transform.rotation = Quaternion.Euler(0, 0, 180); } }
private void HandleReceivedInput(InputEventArg <EnemyInput> eventArgs) { if (dying) { return; } switch (eventArgs._command) { case EnemyInput.Attack: _animator.SetToggle("Attack", true); _launcher.LaunchDirection = _input.GetMovingDirection().x > 0 ? Vector2.right : Vector2.left; _launcher.Launch(); break; } HandleEndurance(); }
private bool Shoot() { float currentTime = Time.time; if (currentTime < _lastLaunchTime + fireCoolTime) { // クールタイム中であれば失敗 return(false); } if (gunBlocker.Block()) { // 発射遮断中であれば失敗 return(false); } projectileLauncher.Launch(); // 発射時間を更新 _lastLaunchTime = currentTime; return(true); }
private void Fire() { _projectileLauncher.Launch(_photonView.Owner); }
void FireWeapon(WeaponData weapon, Transform transform) { ProjectileLauncher.Launch(weapon.projectile, weapon.fireSFX, transform); }