6using System.Collections;
7using System.Collections.Generic;
13[RequireComponent(typeof(Rigidbody))]
17 private float rotationSpeed = 1f;
19 private float centeringSpeed = 4f;
21 private bool singleScene =
false;
23 private Rigidbody rbody;
24 private bool isFalling;
25 private Vector3 cardFallRotation;
26 private bool fallToZero;
27 private float startZPos;
31 rbody = GetComponent<Rigidbody>();
32 rbody.useGravity =
false;
33 startZPos = transform.position.z;
40 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(cardFallRotation), Time.deltaTime * rotationSpeed);
46 transform.position = Vector3.Lerp(transform.position,
new Vector3(0, 0, startZPos), Time.deltaTime * centeringSpeed);
47 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(Vector3.zero), Time.deltaTime * centeringSpeed);
48 if (Vector3.Distance(transform.position,
new Vector3(0, 0, startZPos)) < 0.0025f)
50 transform.position =
new Vector3(0, 0, startZPos);
56 if (transform.position.y < -4)
59 rbody.useGravity =
false;
60 rbody.velocity = Vector3.zero;
61 transform.position =
new Vector3(0, 8, startZPos);
77 rbody.useGravity =
true;
79 cardFallRotation =
new Vector3(0, 0, fallRotation);
Credit Erdener Gonenc - @PixelEnvision.