mirror of
https://github.com/nothke/quality-control.git
synced 2024-12-23 00:07:28 +00:00
26 lines
568 B
C#
26 lines
568 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ConveyorBelt : MonoBehaviour
|
|
{
|
|
Rigidbody _rb;
|
|
Rigidbody rb { get { if (!_rb) _rb = GetComponent<Rigidbody>(); return _rb; } }
|
|
|
|
public float speed = 1;
|
|
|
|
Vector3 startPosition;
|
|
|
|
private void Start()
|
|
{
|
|
startPosition = rb.position;
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
rb.position = startPosition;
|
|
Vector3 targetSpeed = speed * transform.forward;
|
|
rb.MovePosition(rb.position + targetSpeed * Time.deltaTime);
|
|
}
|
|
}
|