private Rigidbody rb; public float currentFallDelay = 1f; float minFallDelay = 0.3f; public float accelerationTime = 10; private float maxFallDelay; private float time; void Start() { rb = GetComponent<Rigidbody>(); minFallDelay = currentFallDelay; time = 0; } public IEnumerator FallDelay() { rb.isKinematic = true; yield return new WaitForSeconds(1f); while (true) { currentFallDelay = Mathf.SmoothStep(minFallDelay, maxFallDelay, time / accelerationTime); transform.position += Vector3.down * currentFallDelay * Time.deltaTime; time += Time.deltaTime; yield return null; } } void OnCollisionEnter(Collision col) { if (rb.isKinematic && col.collider.CompareTag("Player")) { StartCoroutine(FallDelay()); } }
yield return new WaitForSeconds(1f)
FallDelay()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)