Compare commits

...

2 Commits

Author SHA1 Message Date
317096027e лед и шары 2.0 2025-11-14 02:08:11 +03:00
20b916d0e1 лед и шары 2025-11-14 02:06:26 +03:00
492 changed files with 20296 additions and 8309 deletions

View File

@ -46,6 +46,7 @@
<Analyzer Include="D:\UNITY\6000.2.11f1\Editor\Data\Tools\Unity.SourceGenerators\Unity.UIToolkit.SourceGenerator.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Scripts\RollingHazard.cs" />
<Compile Include="Assets\TextMesh Pro\Examples &amp; Extras\Scripts\TMP_TextEventHandler.cs" />
<Compile Include="Assets\TextMesh Pro\Examples &amp; Extras\Scripts\EnvMapAnimator.cs" />
<Compile Include="Assets\TextMesh Pro\Examples &amp; Extras\Scripts\TMP_TextSelector_A.cs" />
@ -90,6 +91,7 @@
<Compile Include="Assets\TextMesh Pro\Examples &amp; Extras\Scripts\TextMeshProFloatingText.cs" />
<Compile Include="Assets\Scripts\MovingPlatform.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="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" />

View File

@ -0,0 +1,157 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4895762346311792966
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5112529374957775571}
- component: {fileID: 6363545691155412689}
- component: {fileID: 7905298161138606236}
- component: {fileID: 326177470854304081}
- component: {fileID: 4315898701547426592}
- component: {fileID: 5807832432957972605}
m_Layer: 0
m_Name: HazardBall_1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5112529374957775571
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4895762346311792966}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -68.53, y: 1.24, z: 145.8}
m_LocalScale: {x: 2.17, y: 2.17, z: 2.17}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &6363545691155412689
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4895762346311792966}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &7905298161138606236
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4895762346311792966}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: ffb9d73c5a527ed4c9e6aa009010d38c, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!135 &326177470854304081
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4895762346311792966}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &4315898701547426592
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4895762346311792966}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8f74548a429b405384cf83ecdb3be192, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::RollingHazard
pursuitForce: 50
maxSpeed: 10
destroyYLevel: -5
--- !u!54 &5807832432957972605
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4895762346311792966}
serializedVersion: 5
m_Mass: 1
m_LinearDamping: 0
m_AngularDamping: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 20064ee6711e2a542b242d038ffa5dde
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -4,16 +4,20 @@ public class BallController : MonoBehaviour
{
[Header("Настройки Движения")]
[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 jumpForce = 7f; // Сила прыжка
[SerializeField] private float trampolineBounceForce = 1.5f; // Множитель для отскока от батута
[SerializeField] private GameObject gameOverPanel;
[Header("Настройки Льда")]
[SerializeField] private float iceAcceleration = 50f;
[SerializeField] private float iceDeceleration = 0.5f;
[Header("Настройки Контроля")]
[Tooltip("Сила торможения/трения. Применяется, когда нет ввода.")]
[SerializeField] private float decelerationRate = 5f; // Сила, замедляющая шарик (трение)
[SerializeField] private float groundCheckDistance = 0.1f; // Дистанция для проверки земли
private Rigidbody rb;
@ -21,6 +25,10 @@ public class BallController : MonoBehaviour
private float sphereRadius;
private bool isDead = false;
// Внутренние переменные для хранения текущих параметров
private float currentAcceleration;
private float currentDeceleration;
// Переменные для считывания ввода
private float moveX;
private float moveZ;
@ -56,11 +64,23 @@ public class BallController : MonoBehaviour
{
isGrounded = false;
Vector3 origin = transform.position;
if (Physics.Raycast(origin, -Vector3.up, out RaycastHit hit, sphereRadius + groundCheckDistance))
{
if (hit.normal.y > 0.7f)
{
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()
{
Vector3 currentVel = rb.linearVelocity;
Vector3 currentVel = rb.linearVelocity;
// 1. Ускорение по X (A/D)
// Используем currentAcceleration
if (Mathf.Abs(moveX) > 0.01f)
{
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(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()
{
// Используем currentDeceleration
Vector3 horizontalVel = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
// Применяем силу, противоположную скорости (имитация трения)
if (horizontalVel.sqrMagnitude > 0.01f)
{
// Направление силы, противоположное скорости
Vector3 frictionForce = -horizontalVel.normalized * decelerationRate;
Vector3 frictionForce = -horizontalVel.normalized * currentDeceleration;
rb.AddForce(frictionForce, ForceMode.Acceleration);
}
else
{
// Если скорость очень низка, останавливаем горизонтальное движение, чтобы избежать "дрейфа"
rb.linearVelocity = new Vector3(0, rb.linearVelocity.y, 0);
}
}
@ -181,21 +198,18 @@ public class BallController : MonoBehaviour
{
if (isDead) return;
isDead = true;
// 1. Останавливаем шарик
if (rb != null)
{
rb.linearVelocity = Vector3.zero; // Используем linearVelocity как в вашем коде
rb.isKinematic = true; // Отключаем физику
rb.linearVelocity = Vector3.zero;
rb.isKinematic = true;
}
// 2. Показываем меню
if (gameOverPanel != null)
{
gameOverPanel.SetActive(true);
}
// 3. Останавливаем время (опционально, но рекомендуется для меню)
Time.timeScale = 0f;
}
}

View File

@ -0,0 +1,58 @@
using UnityEngine;
public class RollingHazard : MonoBehaviour
{
[Header("Настройки Преследования")]
[SerializeField] private float pursuitForce = 50f; // Сила, с которой шар катится за игроком
[SerializeField] private float maxSpeed = 10f; // Ограничение максимальной скорости
[SerializeField] private float destroyYLevel = -5f; // Координата Y, при которой шар удаляется
private Transform playerTarget;
private Rigidbody rb;
private bool isPursuing = false;
void Awake()
{
rb = GetComponent<Rigidbody>();
if (GetComponent<Collider>() != null)
{
GetComponent<Collider>().isTrigger = false;
}
}
public void StartPursuit(Transform target)
{
playerTarget = target;
isPursuing = true;
}
void FixedUpdate()
{
// 1. Логика преследования
if (isPursuing && playerTarget != null)
{
// Направление к игроку
Vector3 directionToPlayer = (playerTarget.position - transform.position).normalized;
directionToPlayer.y = 0; // Только горизонтальное движение
// Добавляем силу, чтобы шар катился
rb.AddForce(directionToPlayer * pursuitForce, ForceMode.Acceleration);
// Ограничиваем горизонтальную скорость
Vector3 flatVel = new Vector3(rb.linearVelocity.x, 0, rb.linearVelocity.z);
if (flatVel.magnitude > maxSpeed)
{
Vector3 limitedVel = flatVel.normalized * maxSpeed;
rb.linearVelocity = new Vector3(limitedVel.x, rb.linearVelocity.y, limitedVel.z);
}
}
// 2. Логика удаления при падении
if (transform.position.y < destroyYLevel)
{
Destroy(gameObject);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8f74548a429b405384cf83ecdb3be192
timeCreated: 1763073055

View File

@ -0,0 +1,63 @@
using UnityEngine;
using System.Collections.Generic;
public class TriggerPlatform : MonoBehaviour
{
[Header("Настройки Шаров")]
public List<GameObject> hazardBalls;
[SerializeField] private float initialPushForce = 5f; // Начальный толчок для старта движения
[SerializeField] private float triggerDelay = 0.5f; // Задержка перед началом движения
private bool hasBeenTriggered = false;
void Start()
{
// При старте убеждаемся, что все шары статичны
foreach (GameObject ball in hazardBalls)
{
Rigidbody rb = ball.GetComponent<Rigidbody>();
if (rb != null)
{
rb.isKinematic = true;
}
if (ball.GetComponent<RollingHazard>() == null)
{
ball.AddComponent<RollingHazard>();
}
}
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.GetComponent<BallController>() != null && !hasBeenTriggered)
{
hasBeenTriggered = true;
Invoke("ActivateHazards", triggerDelay);
}
}
private void ActivateHazards()
{
foreach (GameObject ball in hazardBalls)
{
Rigidbody rb = ball.GetComponent<Rigidbody>();
if (rb != null)
{
// 1. включаем физику
rb.isKinematic = false;
// 2. Определяем направление к игроку
Vector3 direction = (transform.position - ball.transform.position).normalized;
Vector3 pushDirection = (ball.transform.position - transform.position);
pushDirection.y = 0;
pushDirection = pushDirection.normalized;
rb.AddForce(transform.forward * initialPushForce, ForceMode.Impulse);
// Активируем скрипт RollingHazard для постоянного преследования игрока
ball.GetComponent<RollingHazard>().StartPursuit(FindObjectOfType<BallController>().transform);
}
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fad1eb58e8fbda44aa43402d9602939a

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c3c4f86eca16280408fdc7a414b0d7fc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6c0705fef53b4094a9941774f607f851
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More