Untitled
unknown
plain_text
9 months ago
993 B
2
Indexable
public class TrainScript : MonoBehaviour { private bool isDrivingFullSpeed = false; private float trainSpeed = 0.5f; private void FixedUpdate() { MovingTrain(); } private void MovingTrain() { transform.position = transform.position + transform.forward * trainSpeed * Time.fixedDeltaTime; if (!isDrivingFullSpeed) { trainSpeed += trainSpeed / 4 * Time.deltaTime; if (trainSpeed >= 9.9) { isDrivingFullSpeed = true; trainSpeed = 10f; } } } } public class StickingBoxScript : MonoBehaviour { private void OnTriggerEnter(Collider other) { if(other.CompareTag("sticking")) { other.transform.parent = transform.parent.transform; } } private void OnTriggerExit(Collider other) { if (other.CompareTag("sticking")) { other.transform.parent = null; } } }
Editor is loading...
Leave a Comment