public void DoDamage(int hitDirection = 0) { if (_camera == null) { return; } if (_gameSceneManager == null) { return; } // Local Variables Ray ray; RaycastHit hit; bool isSomethingHit = false; ray = _camera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); isSomethingHit = Physics.Raycast(ray, out hit, 1000.0f, 1 << _aiBodyPartLayer); if (isSomethingHit) { AIStateMachine stateMachine = _gameSceneManager.GetAIStateMachine(hit.rigidbody.GetInstanceID()); Debug.Log("Body part is: " + hit.rigidbody.GetInstanceID()); if (stateMachine) { Debug.Log("This has worked"); stateMachine.TakeDamage(hit.point, ray.direction * 1.0f, 50, hit.rigidbody, this, 0); } } }
public void DoDamage(int hitDirection = 0) { if (_camera == null) { return; } if (_gameSceneManager == null) { return; } Ray ray; RaycastHit hit; bool isSomethingHit = false; ray = _camera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); isSomethingHit = Physics.Raycast(ray, out hit, 1000, 1 << _aiBodyPartLayer); if (isSomethingHit) { //used to search dictionary to find which zombie has been hit with ray AIStateMachine stateMachine = _gameSceneManager.GetAIStateMachine(hit.rigidbody.GetInstanceID()); if (stateMachine) { //parameters taken from current weapon stateMachine.TakeDamage(hit.point, ray.direction * 1.0f, 100, hit.rigidbody, this, 0); } } }
// ------------------------------------------------------------------------- // 类 : DoDamage // 介绍 : 攻击 // ------------------------------------------------------------------------- public void DoDamage(int hitDirection = 0) { if (_camera == null) { return; } if (_gameSceneManager == null) { return; } Ray ray; RaycastHit hit; bool isSomethingHit = false; ray = _camera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0.0f)); isSomethingHit = Physics.Raycast(ray, out hit, 1000.0f, 1 << _aiBodyPartLayer); if (isSomethingHit) { AIStateMachine stateMachine = _gameSceneManager.GetAIStateMachine(hit.rigidbody.GetInstanceID()); if (stateMachine) { stateMachine.TakeDamage(hit.point, ray.direction * 5.0f, 25, hit.rigidbody, this, 0); } } }