лед и шары
This commit is contained in:
parent
ba1571c9ac
commit
20b916d0e1
@ -46,6 +46,7 @@
|
|||||||
<Analyzer Include="D:\UNITY\6000.2.11f1\Editor\Data\Tools\Unity.SourceGenerators\Unity.UIToolkit.SourceGenerator.dll" />
|
<Analyzer Include="D:\UNITY\6000.2.11f1\Editor\Data\Tools\Unity.SourceGenerators\Unity.UIToolkit.SourceGenerator.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Assets\Scripts\RollingHazard.cs" />
|
||||||
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\TMP_TextEventHandler.cs" />
|
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\TMP_TextEventHandler.cs" />
|
||||||
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\EnvMapAnimator.cs" />
|
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\EnvMapAnimator.cs" />
|
||||||
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\TMP_TextSelector_A.cs" />
|
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\TMP_TextSelector_A.cs" />
|
||||||
@ -90,6 +91,7 @@
|
|||||||
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\TextMeshProFloatingText.cs" />
|
<Compile Include="Assets\TextMesh Pro\Examples & Extras\Scripts\TextMeshProFloatingText.cs" />
|
||||||
<Compile Include="Assets\Scripts\MovingPlatform.cs" />
|
<Compile Include="Assets\Scripts\MovingPlatform.cs" />
|
||||||
<Compile Include="Assets\Scripts\TrailController.cs" />
|
<Compile Include="Assets\Scripts\TrailController.cs" />
|
||||||
|
<Compile Include="Assets\Scripts\TriggerPlatform.cs" />
|
||||||
<None Include="Library\PackageCache\com.unity.ai.navigation@5218e4bf7edc\ValidationExceptions.json" />
|
<None Include="Library\PackageCache\com.unity.ai.navigation@5218e4bf7edc\ValidationExceptions.json" />
|
||||||
<None Include="D:\UNITY\6000.2.11f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.modules.subsystems\package.json" />
|
<None Include="D:\UNITY\6000.2.11f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.modules.subsystems\package.json" />
|
||||||
<None Include="Library\PackageCache\com.unity.render-pipelines.universal@35ca8d108413\package.json" />
|
<None Include="Library\PackageCache\com.unity.render-pipelines.universal@35ca8d108413\package.json" />
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -4,16 +4,20 @@ public class BallController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[Header("Настройки Движения")]
|
[Header("Настройки Движения")]
|
||||||
[SerializeField] private float maxSpeed = 15f; // Максимальная скорость на земле
|
[SerializeField] private float maxSpeed = 15f; // Максимальная скорость на земле
|
||||||
[SerializeField] private float accelerationRate = 200f; // Как быстро шарик разгоняется
|
[SerializeField] private float defaultAcceleration = 200f; // Как быстро шарик разгоняется
|
||||||
|
[SerializeField] private float defaultDeceleration = 10f; // трение
|
||||||
[SerializeField] private float airControlSpeed = 5f; // Скорость управления в прыжке
|
[SerializeField] private float airControlSpeed = 5f; // Скорость управления в прыжке
|
||||||
[SerializeField] private float jumpForce = 7f; // Сила прыжка
|
[SerializeField] private float jumpForce = 7f; // Сила прыжка
|
||||||
[SerializeField] private float trampolineBounceForce = 1.5f; // Множитель для отскока от батута
|
[SerializeField] private float trampolineBounceForce = 1.5f; // Множитель для отскока от батута
|
||||||
[SerializeField] private GameObject gameOverPanel;
|
[SerializeField] private GameObject gameOverPanel;
|
||||||
|
|
||||||
|
[Header("Настройки Льда")]
|
||||||
|
[SerializeField] private float iceAcceleration = 50f;
|
||||||
|
[SerializeField] private float iceDeceleration = 0.5f;
|
||||||
|
|
||||||
[Header("Настройки Контроля")]
|
[Header("Настройки Контроля")]
|
||||||
[Tooltip("Сила торможения/трения. Применяется, когда нет ввода.")]
|
[Tooltip("Сила торможения/трения. Применяется, когда нет ввода.")]
|
||||||
[SerializeField] private float decelerationRate = 5f; // Сила, замедляющая шарик (трение)
|
[SerializeField] private float decelerationRate = 5f; // Сила, замедляющая шарик (трение)
|
||||||
|
|
||||||
[SerializeField] private float groundCheckDistance = 0.1f; // Дистанция для проверки земли
|
[SerializeField] private float groundCheckDistance = 0.1f; // Дистанция для проверки земли
|
||||||
|
|
||||||
private Rigidbody rb;
|
private Rigidbody rb;
|
||||||
@ -21,6 +25,10 @@ public class BallController : MonoBehaviour
|
|||||||
private float sphereRadius;
|
private float sphereRadius;
|
||||||
private bool isDead = false;
|
private bool isDead = false;
|
||||||
|
|
||||||
|
// Внутренние переменные для хранения текущих параметров
|
||||||
|
private float currentAcceleration;
|
||||||
|
private float currentDeceleration;
|
||||||
|
|
||||||
// Переменные для считывания ввода
|
// Переменные для считывания ввода
|
||||||
private float moveX;
|
private float moveX;
|
||||||
private float moveZ;
|
private float moveZ;
|
||||||
@ -56,11 +64,23 @@ public class BallController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
isGrounded = false;
|
isGrounded = false;
|
||||||
Vector3 origin = transform.position;
|
Vector3 origin = transform.position;
|
||||||
|
|
||||||
if (Physics.Raycast(origin, -Vector3.up, out RaycastHit hit, sphereRadius + groundCheckDistance))
|
if (Physics.Raycast(origin, -Vector3.up, out RaycastHit hit, sphereRadius + groundCheckDistance))
|
||||||
{
|
{
|
||||||
if (hit.normal.y > 0.7f)
|
if (hit.normal.y > 0.7f)
|
||||||
{
|
{
|
||||||
isGrounded = true;
|
isGrounded = true;
|
||||||
|
|
||||||
|
if (hit.collider.CompareTag("Ice"))
|
||||||
|
{
|
||||||
|
currentAcceleration = iceAcceleration;
|
||||||
|
currentDeceleration = iceDeceleration;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentAcceleration = defaultAcceleration;
|
||||||
|
currentDeceleration = defaultDeceleration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,41 +116,38 @@ public class BallController : MonoBehaviour
|
|||||||
|
|
||||||
private void ApplyAcceleration()
|
private void ApplyAcceleration()
|
||||||
{
|
{
|
||||||
Vector3 currentVel = rb.linearVelocity;
|
Vector3 currentVel = rb.linearVelocity;
|
||||||
|
|
||||||
// 1. Ускорение по X (A/D)
|
// Используем currentAcceleration
|
||||||
if (Mathf.Abs(moveX) > 0.01f)
|
if (Mathf.Abs(moveX) > 0.01f)
|
||||||
{
|
{
|
||||||
if (Mathf.Abs(currentVel.x) < maxSpeed)
|
if (Mathf.Abs(currentVel.x) < maxSpeed)
|
||||||
{
|
{
|
||||||
rb.AddForce(new Vector3(moveX, 0, 0) * accelerationRate, ForceMode.Acceleration);
|
rb.AddForce(new Vector3(moveX, 0, 0) * currentAcceleration, ForceMode.Acceleration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Ускорение по Z (W/S)
|
|
||||||
if (Mathf.Abs(moveZ) > 0.01f)
|
if (Mathf.Abs(moveZ) > 0.01f)
|
||||||
{
|
{
|
||||||
if (Mathf.Abs(currentVel.z) < maxSpeed)
|
if (Mathf.Abs(currentVel.z) < maxSpeed)
|
||||||
{
|
{
|
||||||
rb.AddForce(new Vector3(0, 0, moveZ) * accelerationRate, ForceMode.Acceleration);
|
rb.AddForce(new Vector3(0, 0, moveZ) * currentAcceleration, ForceMode.Acceleration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyDeceleration()
|
private void ApplyDeceleration()
|
||||||
{
|
{
|
||||||
|
// Используем currentDeceleration
|
||||||
Vector3 horizontalVel = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
|
Vector3 horizontalVel = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
|
||||||
|
|
||||||
// Применяем силу, противоположную скорости (имитация трения)
|
|
||||||
if (horizontalVel.sqrMagnitude > 0.01f)
|
if (horizontalVel.sqrMagnitude > 0.01f)
|
||||||
{
|
{
|
||||||
// Направление силы, противоположное скорости
|
Vector3 frictionForce = -horizontalVel.normalized * currentDeceleration;
|
||||||
Vector3 frictionForce = -horizontalVel.normalized * decelerationRate;
|
|
||||||
rb.AddForce(frictionForce, ForceMode.Acceleration);
|
rb.AddForce(frictionForce, ForceMode.Acceleration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Если скорость очень низка, останавливаем горизонтальное движение, чтобы избежать "дрейфа"
|
|
||||||
rb.linearVelocity = new Vector3(0, rb.linearVelocity.y, 0);
|
rb.linearVelocity = new Vector3(0, rb.linearVelocity.y, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,21 +198,18 @@ public class BallController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (isDead) return;
|
if (isDead) return;
|
||||||
isDead = true;
|
isDead = true;
|
||||||
|
|
||||||
// 1. Останавливаем шарик
|
|
||||||
if (rb != null)
|
if (rb != null)
|
||||||
{
|
{
|
||||||
rb.linearVelocity = Vector3.zero; // Используем linearVelocity как в вашем коде
|
rb.linearVelocity = Vector3.zero;
|
||||||
rb.isKinematic = true; // Отключаем физику
|
rb.isKinematic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Показываем меню
|
|
||||||
if (gameOverPanel != null)
|
if (gameOverPanel != null)
|
||||||
{
|
{
|
||||||
gameOverPanel.SetActive(true);
|
gameOverPanel.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Останавливаем время (опционально, но рекомендуется для меню)
|
|
||||||
Time.timeScale = 0f;
|
Time.timeScale = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user