5 using System.Collections.Generic;
16 [Header(
"How fast does object rotate?")]
18 private float rotationIncrement = 200;
20 [Header(
"Start scale of the object?")]
22 private float minScale = 1.0f;
24 [Header(
"Final scale of the object?")]
26 private float maxScale = 9.0f;
28 [Header(
"How fast does object grow?")]
30 private float scaleSpeed = 30.0f;
32 [Header(
"Should object rotate after growing?")]
34 private bool rotationActive =
false;
36 [Header(
"Should object grow before rotating?")]
38 private bool growingActive =
true;
40 [Header(
"Rotation occurs about which axes?")]
42 private bool xAxisRotation =
false;
44 private bool yAxisRotation =
true;
46 private bool zAxisRotation =
false;
48 private float currentScale;
49 private float elapsedTime;
59 currentScale = minScale;
64 elapsedTime += Time.unscaledDeltaTime;
66 if (growingActive && currentScale < maxScale)
68 currentScale = minScale + (scaleSpeed * (maxScale * Mathf.Pow(elapsedTime, 2.0f)));
71 transform.localScale =
new Vector3(currentScale, currentScale, currentScale);
75 float increment = Time.deltaTime * rotationIncrement;
76 float xRotation = xAxisRotation ? increment : 0;
77 float yRotation = yAxisRotation ? increment : 0;
78 float zRotation = zAxisRotation ? increment : 0;
79 transform.Rotate(xRotation, yRotation, zRotation);