Working conveyor belt

This commit is contained in:
nothke 2024-08-17 10:57:32 +02:00
parent 5593d2a0da
commit f506fbd6b4
2 changed files with 1586 additions and 16 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,24 +4,22 @@ using UnityEngine;
public class ConveyorBelt : MonoBehaviour public class ConveyorBelt : MonoBehaviour
{ {
Rigidbody _rb;
Rigidbody rb { get { if (!_rb) _rb = GetComponent<Rigidbody>(); return _rb; } }
public float speed = 1; public float speed = 1;
List<ContactPoint> contactPoints = new List<ContactPoint>(); Vector3 startPosition;
private void OnCollisionStay(Collision collision) private void Start()
{ {
Vector3 targetSpeed = speed * Vector3.forward; startPosition = rb.position;
}
Vector3 vel = collision.relativeVelocity; private void FixedUpdate()
{
int count = collision.GetContacts(contactPoints); rb.position = startPosition;
Vector3 targetSpeed = speed * transform.forward;
if (collision.rigidbody) rb.MovePosition(rb.position + targetSpeed * Time.deltaTime);
{
for (int i = 0; i < count; i++)
{
}
}
} }
} }