void Update() { if (!m_Game.IsFinish()) { if (m_Game.IsGameStarted()) { // for resolve collisions float curVelocity = Body.velocity.magnitude; if (m_PrevSpeed > curVelocity) { m_MoveSpeed.SetSpeed(curVelocity); } float speed = Mathf.Min(m_MoveSpeed.GetSpeed(), m_MoveSpeed.GetMaxSpeed() * m_SurfaceInfo.GetSurfaceSpeedMultiplayer()); float dumpSpeed = 1; if (m_IsInputAvailable) { dumpSpeed = 1 - ((Time.time - m_LastInputTime) / DumpSpeedTurnTime * (speed / m_MoveSpeed.GetMaxSpeed())); } float resultSpeed = speed * dumpSpeed; m_MoveSpeed.SetSpeed(resultSpeed); Body.velocity = Body.transform.forward * resultSpeed; m_PrevSpeed = resultSpeed; } } else { if (m_MoveSpeed.GetSpeed() > 0) { m_MoveSpeed.SetSpeed(m_MoveSpeed.GetSpeed() * 0.9f); Body.velocity = Body.transform.forward * m_MoveSpeed.GetSpeed(); } } }
public void SetInput(float inputHorizontalAxis) { if (inputHorizontalAxis > 0.5f || inputHorizontalAxis < -0.5f) { if (!m_IsInputAvailable) { m_LastInputTime = Time.time; m_IsInputAvailable = true; } } else { m_IsInputAvailable = false; } float turnAngle = Body.transform.eulerAngles.y + inputHorizontalAxis * m_RotateSpeed.GetSpeed() * Time.deltaTime; Body.transform.rotation = Quaternion.Euler(0, turnAngle, 0); }