You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
837 B
C#
36 lines
837 B
C#
5 days ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
public class PeekabooMole : MonoBehaviour
|
||
|
{
|
||
|
void OnMouseDown()
|
||
|
{
|
||
|
PeekabooGameManager.Instance.MoleClicked();
|
||
|
StartCoroutine(SquishReaction());
|
||
|
}
|
||
|
|
||
|
IEnumerator SquishReaction()
|
||
|
{
|
||
|
Vector3 originalScale = transform.localScale;
|
||
|
Vector3 squish = originalScale * 0.8f;
|
||
|
float t = 0f;
|
||
|
|
||
|
while (t < 0.1f)
|
||
|
{
|
||
|
transform.localScale = Vector3.Lerp(originalScale, squish, t / 0.1f);
|
||
|
t += Time.deltaTime;
|
||
|
yield return null;
|
||
|
}
|
||
|
|
||
|
t = 0f;
|
||
|
while (t < 0.1f)
|
||
|
{
|
||
|
transform.localScale = Vector3.Lerp(squish, originalScale, t / 0.1f);
|
||
|
t += Time.deltaTime;
|
||
|
yield return null;
|
||
|
}
|
||
|
|
||
|
transform.localScale = originalScale;
|
||
|
}
|
||
|
}
|