You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
905 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeWithCrystals : MonoBehaviour
{
bool characterInWater = false;
public GameObject crystals;
IEnumerator GrowShrinkCoroutine(Vector3 endPosition)
{
float elapsedTime = 0;
Vector3 startPosition = crystals.transform.position;
float time = 0.8f;
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
crystals.transform.position = endPosition;
}
public void Animate()
{
StartCoroutine(GrowShrinkCoroutine(new Vector3(0, 1, 0)));
}
public void returnToPosition()
{
StartCoroutine(GrowShrinkCoroutine(new Vector3(0, 0, 0)));
}
}