void Move() { float distance = Vector3.Distance(transform.position, targetPosition); float vel_y = (isGrounded) ? Mathf.Clamp(0f, 0.1f, m_Rigidbody.velocity.y) : m_Rigidbody.velocity.y; if (distance < slowingRadius) { m_Rigidbody.velocity = new Vector3(0f, vel_y, runSpeed * (distance / slowingRadius)); countdownToIncreaseSpeed = float.MaxValue; } else { m_Rigidbody.velocity = new Vector3(0f, vel_y, runSpeed); } if (inputX < 0f) { LaneLimitBehavior.PreviousLane(); } else if (inputX > 0f) { LaneLimitBehavior.NextLane(); } Vector3 newPosition = new Vector3(LaneLimitBehavior.CurrentLaneLimit(), transform.localPosition.y, transform.localPosition.z); transform.localPosition = Vector3.Slerp(transform.localPosition, newPosition, Time.deltaTime * strafeSpeed); }
private void Start() { ClearGameObjects(); randomSeed = Random.Range(0, int.MaxValue); Random.InitState(randomSeed); LaneLimitBehavior.LaneLimits(laneWidth, xOffset, 1); firstTime = true; if (generate) { DrawTilesMap(0, 0, GetPlatformsToDraw()); } }