Add Unity project

This commit is contained in:
nzagoruiko committed 2026-11-24 14:54:03 +03:00
1 parent e047c50f0e
commit ebbcec3745
1430 files changed
+295478

No files matched your search

@@ -0,0 +1,20 @@
using UnityEngine;
public class PushPhysicsDoors : MonoBehaviour
{
public float pushPower = 5.0f; // Сила толчка
void OnControllerColliderHit(ControllerColliderHit hit)
{
Rigidbody body = hit.collider.attachedRigidbody;
// Проверяем, есть ли у объекта Rigidbody и не отключена ли физика
if (body == null || body.isKinematic) return;
// Рассчитываем направление толчка (только по горизонтали)
Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);
// Толкаем объект в точку касания
body.AddForceAtPosition(pushDir * pushPower, hit.point, ForceMode.Impulse);
}
}