/* * \brief Works out if a value is almost another value (for floating point accuracy) */ public void CallOnCollisionEnter(Collision collision) { m_collisionState = CollisionState.None; foreach (ContactPoint contact in collision) { m_platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>(); if (m_platform != null) { m_platform.resetDeltaA(); } if (isNearly(contact.normal.y, 1.0f, 0.2f)) { m_collisionState = CollisionState.OnFloor; // are we on a special material? m_footMaterial = FootMaterial.Stone; if (contact.otherCollider.tag == "Wood Object") { m_footMaterial = FootMaterial.Wood; } else if (contact.otherCollider.tag == "Metal Object") { m_footMaterial = FootMaterial.Metal; } } else if (isNearly(contact.normal.y, -1.0f, 0.2f)) { m_collisionState = CollisionState.OnRoof; } else { m_collisionState = CollisionState.OnWall; m_ladderClimb.State = LadderState.None; } } if (m_collisionState == CollisionState.OnFloor) { if (m_jumpState != JumpState.Landed) { m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial); } m_jumpState = JumpState.Landed; m_ladderClimb.State = LadderState.None; if (m_player.GetPlayerState() != PlayerState.Turning) { m_player.SetPlayerState(PlayerState.Standing); } //m_ledgeGrabBox.collider.enabled = true; } }
/* * \brief Works out if a value is almost another value (for floating point accuracy) */ public void CallOnCollisionEnter(Collision collision) { m_collisionState = CollisionState.None; foreach (ContactPoint contact in collision) { m_platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>(); if (m_platform != null) { m_platform.resetDeltaA(); } if (isNearly(contact.normal.y, 1.0f, 0.2f)) { m_collisionState = CollisionState.OnFloor; if (m_player.GetPlayerState() == PlayerState.OnLadder) { GetLadder.state = LadderState.AtBase; m_player.SetPlayerState(PlayerState.Standing); } // are we on a special material? m_footMaterial = FootMaterial.Stone; if (contact.otherCollider.tag == "Wood Object") { m_footMaterial = FootMaterial.Wood; } else if (contact.otherCollider.tag == "Metal Object") { m_footMaterial = FootMaterial.Metal; } } else if (isNearly(contact.normal.y, -1.0f, 0.2f)) { m_collisionState = CollisionState.OnRoof; if (contact.otherCollider != null && contact.otherCollider.GetComponent <CSceneObjectPlatform>() != null) { m_player.PushPlayerFromTower(); } } else { if (m_player.GetPlayerState() != PlayerState.OnLadder) { m_collisionState = CollisionState.OnWall; } } } if (m_collisionState == CollisionState.OnFloor) { if (m_jumpState != JumpState.Landed) { m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial); } m_jumpState = JumpState.Landed; if (GetLadder.state == LadderState.JumpingOff) { GetLadder.state = LadderState.None; } if (m_player.GetPlayerState() != PlayerState.Turning && m_player.GetPlayerState() != PlayerState.OnLadder && !m_player.PullingLever(false)) { m_player.SetPlayerState(PlayerState.Standing); } } }