// Update is called once per frame void Update() { // Update wall fade shader position. if (m_wallMat) { Vector4 v4ShaderPos = transform.position; m_wallMat.SetVector(m_shaderUniformHandle, v4ShaderPos); } // Posession input. bool bThrowInput = m_input.GetButton(2); bool bDropInput = m_input.GetButton(1); // Object throwing if (m_possessedObj != null && m_possessedObj != m_human) { // Thowing input. if (m_possessedObj != m_human && bThrowInput) { ThrowPossessed(); } else if (m_possessedObj != m_human && bDropInput) { DropPossessed(); } } // Thow cooldown. m_fCurrentThrowCD -= Time.deltaTime; m_fCurrentStunTime -= Time.deltaTime; // Player stunning if (m_fCurrentStunTime < 0.0f && m_bStunned) { // Unfreeze player input. m_movement.DisableInput(false); // No longer stunned. m_bStunned = false; m_input.enabled = true; // Stop effect. if (m_stunParticles) { m_stunParticles.Stop(); } m_movement.m_AnimationController.SetBool("IsStunned", false); // Can collide with human again. Physics.IgnoreCollision(m_controller, m_humanController, false); } // Possession detection. if (bThrowInput) { RaycastHit hit; RaycastHit humanRayHit; bool bHit = Physics.Raycast ( transform.position - transform.forward + (Vector3.down * 0.7f), transform.forward, out hit, m_fPossessionRange, m_nPossessionMask ); bool bHumanHit = Physics.Raycast ( transform.position - transform.forward, transform.forward, out humanRayHit, m_fPossessionRange, m_nPossessionMask ); if (bHumanHit) { if (humanRayHit.collider.gameObject == m_human && m_fCurrentThrowCD <= 0.0f && m_possessedObj == null) { // Human cannot be possessed if there is another ghost in him that has not been knocked out. if (m_humanScript.GetIsSusceptible()) { PursuePossess(m_human); } } } if (bHit) { Debug.DrawLine(transform.position + (Vector3.down * 0.8f), hit.point); // Detect targets using trigger collider and allow posession if the input and misc conditions are corret. if (hit.collider.tag == "Possessible" && m_possessedObj == null && m_fCurrentThrowCD <= 0.0f) { PursuePossess(hit.collider.gameObject); } } } // Pause if (m_input.StartPressed() && !m_input.m_bUseKeyboard) { PauseMenu m_pauseScript = m_gui.GetComponent <PauseMenu>(); m_pauseScript.SetPaused(!m_pauseScript.GetIsPaused()); } if (m_dashParticles && m_possessedObj == null) { // Play dash particles while dashing. if (m_possessedObj == null && m_movement.GetIsRolling()) { if (!m_dashParticles.isPlaying) { m_dashParticles.Play(); } ParticleSystem.MainModule dashMain = m_dashParticles.main; dashMain.startRotationY = (transform.rotation.eulerAngles.y) / 180.0f * Mathf.PI; } else { if (m_dashParticles.isPlaying) { m_dashParticles.Stop(); } } } }