5a59d8e14f
14 newly-imported Synty Polygon packs (~2.46 GB; FBX/PNG/textures stored in Git LFS per .gitattributes). Enemy-grade characters: Werewolf, Kaiju, FantasyHeroCharacters, Vikings, Western, HorrorCarnival, Dog. Environment: Nature, NatureBiomes, PNB_Core, FantasyKingdom. UI/icons: Icons, InterfaceCore, InterfaceSciFiSoldierHUD. Werewolf + Kaiju back the DR-023 animated enemies; the rest are cataloged for future work in Docs/Vault/06_Roadmap/Synty_Asset_Inventory.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class clownEntranceController : MonoBehaviour
|
|
{
|
|
public Transform[] eyeballs; // List of objects 'eyes' to include
|
|
public float rotationRange = 20.0f; // The range of rotation for eyes
|
|
|
|
|
|
public float smoothness = 5.0f;
|
|
public float frequency = 3f;
|
|
public float timeElapsed = 1.0f;
|
|
|
|
private Quaternion initialRotation;
|
|
private Quaternion targetRotation;
|
|
|
|
private Coroutine entranceCoroutine;
|
|
|
|
void Start()
|
|
{
|
|
//disable script if no objects are in eyeball list
|
|
if (eyeballs.Length == 0)
|
|
{
|
|
Debug.LogError("No objects Detected to Rotate, Disabling script");
|
|
enabled = false;
|
|
return;
|
|
}
|
|
|
|
foreach (Transform eyeball in eyeballs)
|
|
{
|
|
initialRotation = eyeball.localRotation;
|
|
entranceCoroutine = StartCoroutine(RandomizeEyeRotation());
|
|
}
|
|
}
|
|
|
|
IEnumerator RandomizeEyeRotation()
|
|
{
|
|
while (true)
|
|
{
|
|
float randomPitch = Random.Range(-rotationRange, rotationRange);
|
|
float randomYaw = Random.Range(-rotationRange, rotationRange);
|
|
|
|
targetRotation = initialRotation * Quaternion.Euler(randomPitch, randomYaw, 0);
|
|
|
|
float elapsedTime = 0;
|
|
|
|
while (elapsedTime < timeElapsed)
|
|
{
|
|
elapsedTime += Time.deltaTime * smoothness;
|
|
//Apply rotation to each eye
|
|
foreach (Transform eyeball in eyeballs)
|
|
{
|
|
|
|
eyeball.localRotation = Quaternion.Slerp(eyeball.localRotation, targetRotation, elapsedTime);
|
|
yield return null;
|
|
}
|
|
}
|
|
// Delay before next eye movement
|
|
yield return new WaitForSeconds(Random.Range(frequency * 0.75f, frequency * 1.5f));
|
|
}
|
|
}
|
|
|
|
|
|
//stops all coroutine's if disabled in scene as one is created for each eye
|
|
void OnDisable()
|
|
{
|
|
if (entranceCoroutine != null)
|
|
{
|
|
StopAllCoroutines();
|
|
}
|
|
}
|
|
} |