/* * \brief Called once per frame */ public override void FixedUpdate() { m_lastPlayerPositionAlpha = m_playerPositionAlpha; m_physics.OnFixedUpdate(ref m_playerState); m_playerPositionAlpha -= m_physics.Velocity; m_playerPositionAlpha += m_physics.PlatformVelocity; m_physics.PlatformVelocity = 0.0f; float additionalY = 0.0f; if (m_playerState == GruntState.FallingFromTower) { m_additionalRadius += (0.025f * m_physics.Invert); m_additionalRadius = Mathf.Clamp(m_additionalRadius, -3.0f, 3.0f); m_playerPositionAlpha = m_lastPlayerPositionAlpha; } float yPosition = transform.position.y + additionalY; m_position = new Vector3( Mathf.Sin(m_playerPositionAlpha * Mathf.Deg2Rad) * (PlayerPathRadius + m_additionalRadius), yPosition, Mathf.Cos(m_playerPositionAlpha * Mathf.Deg2Rad) * (PlayerPathRadius + m_additionalRadius) ); // Animate and position the player model mesh { if (m_playerState == GruntState.Turning) { } else { if (m_physics.Direction > 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); } else if (m_physics.Direction < 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0)); } else if (m_physics.MovingDirection > 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); } else if (m_physics.MovingDirection < 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0)); } } m_animation.OnFixedUpdate(ref m_playerState, m_physics, m_physics.GetFootMaterial()); } if (m_playerState == GruntState.FallingFromTower && (Time.time * 1000.0f) - m_dead.time > 3000) { OnDeath(); } base.FixedUpdate(); }
/* * \brief Called once per frame */ public override void FixedUpdate() { if (m_ticksInContactWithPlayer > 1) { CEntityPlayer.GetInstance().PushPlayerFromTower(); m_ticksInContactWithPlayer = 0; m_playerDetected = false; } if (m_playerDetected) { if (m_resetTimer + TimeToReset < Time.time) { //reset detection m_playerDetected = false; m_playerState = GruntState.Turning; if (m_physics.MovingDirection == 1) { m_physics.MovingDirection = -1; //m_physics.MovingDirection = -1; } else if (m_physics.MovingDirection == -1) { m_physics.MovingDirection = 1; //m_direction = 1; } } } if (m_playerPositionAlpha > 360.0f) { m_playerPositionAlpha -= 360.0f; } else if (m_playerPositionAlpha <= -360.0f) { m_playerPositionAlpha += 360.0f; } m_lastPlayerPositionAlpha = m_playerPositionAlpha; m_physics.OnFixedUpdate(ref m_playerState, m_playerDetected); m_playerPositionAlpha -= m_physics.Velocity; m_playerPositionAlpha += m_physics.PlatformVelocity; m_physics.PlatformVelocity = 0.0f; float additionalY = 0.0f; if (m_playerState == GruntState.FallingFromTower) { m_additionalRadius += (0.025f * m_physics.Invert); m_additionalRadius = Mathf.Clamp(m_additionalRadius, -3.0f, 3.0f); m_playerPositionAlpha = m_lastPlayerPositionAlpha; } float yPosition = transform.position.y + additionalY; m_position = new Vector3( Mathf.Sin(m_playerPositionAlpha * Mathf.Deg2Rad) * (PlayerPathRadius + m_additionalRadius), yPosition, Mathf.Cos(m_playerPositionAlpha * Mathf.Deg2Rad) * (PlayerPathRadius + m_additionalRadius) ); // Animate and position the player model mesh { if (m_playerState == GruntState.Turning) { //Debug.Log("NOT IN ROTATION CODE"); } else { //Debug.Log("rOTATION"); if (m_physics.Direction > 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); } else if (m_physics.Direction < 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0)); } else if (m_physics.MovingDirection > 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); } else if (m_physics.MovingDirection < 0) { m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0)); } } int mDirection = m_physics.MovingDirection; m_animation.OnFixedUpdate(ref m_playerState, ref mDirection, m_physics, m_physics.GetFootMaterial(), m_playerDetected); m_physics.MovingDirection = mDirection; } if (m_playerState == GruntState.FallingFromTower && (Time.time * 1000.0f) - m_dead.time > 3000) { OnDeath(); } base.FixedUpdate(); }