Started building house and refined the interact system
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CarouselController : MonoBehaviour
|
||||
{
|
||||
[Header("Ride Speed")]
|
||||
[Range(-30, 30)]
|
||||
public float rideSpeed = -12.0f;
|
||||
|
||||
[Header("Base Platform")]
|
||||
public GameObject Platform;
|
||||
|
||||
[Header("Cranks")]
|
||||
public Transform[] Cranks;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
//rotate main platform ride
|
||||
Platform.transform.Rotate(Vector3.up * rideSpeed * Time.deltaTime);
|
||||
|
||||
//rotate cranks based on ride speed
|
||||
foreach (Transform crank in Cranks)
|
||||
{
|
||||
crank.Rotate(Vector3.forward * (rideSpeed*1.25f) * Time.deltaTime * 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a77a53b3522c56b43a02befc90e2aec6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CarouselHorseController : MonoBehaviour
|
||||
{
|
||||
private Vector3 originalLocalPosition; // Original local position
|
||||
public float maxDistance = 0.4f;
|
||||
public float speed = 0.3f;
|
||||
public bool reverseMotion = false; // Reverse the motion
|
||||
|
||||
private float startTime;
|
||||
private bool movingToEnd = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
originalLocalPosition = transform.localPosition;
|
||||
startTime = Time.time;
|
||||
}
|
||||
|
||||
|
||||
// Used to smooth out the motion as it reaches its destinations
|
||||
private float SmoothStep(float t)
|
||||
{
|
||||
return t * t * (3f - 2f * t);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float distanceCovered = (Time.time - startTime) * speed;
|
||||
float fractionOfJourney = distanceCovered / maxDistance;
|
||||
fractionOfJourney = Mathf.Clamp01(fractionOfJourney);
|
||||
|
||||
if (reverseMotion)
|
||||
{
|
||||
movingToEnd = !movingToEnd;
|
||||
reverseMotion = false;
|
||||
}
|
||||
|
||||
//get Original position to know where to return
|
||||
Vector3 startLocalPosition = originalLocalPosition;
|
||||
|
||||
//get Target position to move to. Change Vector3.up to change direction of where Target is.
|
||||
Vector3 endLocalPosition = originalLocalPosition + Vector3.up * maxDistance;
|
||||
|
||||
// Used to track local position of objects if parent shapes are moving in scene
|
||||
if (transform.parent != null)
|
||||
{
|
||||
Matrix4x4 parentMatrix = transform.parent.localToWorldMatrix;
|
||||
|
||||
startLocalPosition = parentMatrix.MultiplyPoint3x4(startLocalPosition);
|
||||
endLocalPosition = parentMatrix.MultiplyPoint3x4(endLocalPosition);
|
||||
}
|
||||
|
||||
// Move objects to target destination
|
||||
if (movingToEnd)
|
||||
{
|
||||
float easedFraction = SmoothStep(fractionOfJourney);
|
||||
transform.position = Vector3.Lerp(startLocalPosition, endLocalPosition, easedFraction);
|
||||
}
|
||||
else
|
||||
{
|
||||
float easedFraction = SmoothStep(fractionOfJourney);
|
||||
transform.position = Vector3.Lerp(endLocalPosition, startLocalPosition, easedFraction);
|
||||
}
|
||||
|
||||
if (fractionOfJourney >= 1.0f)
|
||||
{
|
||||
movingToEnd = !movingToEnd;
|
||||
startTime = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f867758caebb9d4aae862210f152cf2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d397a9b9655e3ac428f1b414f8b7c30f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClownGameController : MonoBehaviour
|
||||
{
|
||||
public GameObject clownHead;
|
||||
private float timeCounter = 0.0f;
|
||||
public float rotationAmount = 40f;
|
||||
|
||||
[Range(0,5)]
|
||||
public float speed = 0.5f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float rotationSpeed = speed / rotationAmount;
|
||||
timeCounter += rotationAmount * Time.deltaTime * rotationSpeed;
|
||||
float rotationOffset = Mathf.Sin(timeCounter) * rotationAmount;
|
||||
clownHead.transform.localRotation = Quaternion.Euler(0, rotationOffset, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ae1660937d8062428038cf6ecf8b7af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FerrisWheelController : MonoBehaviour
|
||||
{
|
||||
[Header("Ride Controls")]
|
||||
public float rotationSpeed = 15.0f;
|
||||
public float rockingSpeed = .2f;
|
||||
public float rockingAmplitude = 18f;
|
||||
|
||||
public Transform[] chairs;
|
||||
public Transform[] wheelsForward;
|
||||
public Transform[] wheelsReverse;
|
||||
|
||||
private float timeCounter = 0.0f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Rotate the Ferris wheel
|
||||
transform.Rotate(Vector3.back * rotationSpeed * Time.deltaTime);
|
||||
|
||||
|
||||
//rotate top wheels forwards with rotation speed multiplier
|
||||
foreach (Transform wheelFwd in wheelsForward)
|
||||
{
|
||||
wheelFwd.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime * 10);
|
||||
}
|
||||
|
||||
///rotate bottom wheels backwards with rotation speed multiplier
|
||||
foreach (Transform wheelRev in wheelsReverse)
|
||||
{
|
||||
wheelRev.Rotate(Vector3.back * rotationSpeed * Time.deltaTime * 10);
|
||||
}
|
||||
|
||||
//chair rocking motion
|
||||
foreach (Transform chair in chairs)
|
||||
{
|
||||
timeCounter += rockingSpeed * Time.deltaTime;
|
||||
// rotation speed added to reduce/add more motion depending on ferris wheel speed
|
||||
float rockingOffset = Mathf.Sin(timeCounter) * rockingAmplitude * (rotationSpeed/10);
|
||||
chair.localRotation = Quaternion.Euler(0, 0, rockingOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38ee25c17aa116a419e2f429e43226c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/Synty/PolygonHorrorCarnival/Scripts/FlickerLight.cs
Normal file
71
Assets/Synty/PolygonHorrorCarnival/Scripts/FlickerLight.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FlickerLight : MonoBehaviour
|
||||
{
|
||||
public Light lightAsset;
|
||||
|
||||
// min max intensities
|
||||
public float minIntensity = 1.25f;
|
||||
public float maxIntensity = 2f;
|
||||
|
||||
|
||||
public float flickerSpeed = 3.75f; // Speed of the flickering effect.
|
||||
public float smoothingFactor = 9f; // Controls the smoothness of intensity changes.
|
||||
|
||||
private Coroutine flickerCoroutine;
|
||||
private float targetIntensity;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//check if there is a light
|
||||
if (lightAsset == null)
|
||||
{
|
||||
//attempt to get light transform if none is defined
|
||||
lightAsset = GetComponent<Light>();
|
||||
{
|
||||
//disable script if nothing is found
|
||||
if (!lightAsset)
|
||||
{
|
||||
Debug.LogError("No Light Source Detected, Disabling Script: " + transform.name);
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flickerCoroutine = StartCoroutine(ambientLight());
|
||||
}
|
||||
|
||||
IEnumerator ambientLight()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//random initial target intensity
|
||||
targetIntensity = Random.Range(minIntensity, maxIntensity);
|
||||
|
||||
float elapsedTime = 0f;
|
||||
float startIntensity = lightAsset.intensity;
|
||||
|
||||
while (elapsedTime < 1f)
|
||||
{
|
||||
lightAsset.intensity = Mathf.SmoothStep(startIntensity, targetIntensity, elapsedTime);
|
||||
elapsedTime += Time.deltaTime * smoothingFactor;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
//time to wait before next flicker target
|
||||
yield return new WaitForSeconds(Random.Range(0.05f, 0.2f) / flickerSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
//stops coroutine if disabled in scene
|
||||
void OnDisable()
|
||||
{
|
||||
if (flickerCoroutine != null)
|
||||
{
|
||||
StopCoroutine(flickerCoroutine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6c40806c0a66534d925ad186b68f761
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SimpleRotateCarnival : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool rotX;
|
||||
public float rotXSpeed = 50f;
|
||||
public bool rotY;
|
||||
public float rotYSpeed = 50f;
|
||||
public bool rotZ;
|
||||
public float rotZSpeed = 50f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (rotX == true)
|
||||
{
|
||||
transform.Rotate(Vector3.left * Time.deltaTime * rotXSpeed);
|
||||
}
|
||||
if (rotY == true)
|
||||
{
|
||||
transform.Rotate(Vector3.up * Time.deltaTime * rotYSpeed);
|
||||
}
|
||||
|
||||
if (rotZ == true)
|
||||
{
|
||||
transform.Rotate(Vector3.back * Time.deltaTime * rotZSpeed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e2a1590d54e70347bf830bc88fd12ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SimpleTranslate : MonoBehaviour
|
||||
{
|
||||
public bool moveX;
|
||||
public float moveXSpeed = 2f;
|
||||
public bool moveY;
|
||||
public float moveYSpeed = 2f;
|
||||
public bool moveZ;
|
||||
public float moveZSpeed = 2f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (moveX == true)
|
||||
{
|
||||
transform.Translate(Vector3.left * Time.deltaTime * moveXSpeed);
|
||||
}
|
||||
if (moveY == true)
|
||||
{
|
||||
transform.Translate(Vector3.up * Time.deltaTime * moveYSpeed);
|
||||
}
|
||||
|
||||
if (moveZ == true)
|
||||
{
|
||||
transform.Translate(Vector3.back * Time.deltaTime * moveZSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e83548bd852acd445b13b7142b2276f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Assets/Synty/PolygonHorrorCarnival/Scripts/SpotLightFlicker.cs
Normal file
110
Assets/Synty/PolygonHorrorCarnival/Scripts/SpotLightFlicker.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SpotLightFlicker : MonoBehaviour
|
||||
{
|
||||
public Light spotLight;
|
||||
|
||||
//time between main flicker
|
||||
public float flickerInterval = 7.0f;
|
||||
|
||||
//max intensity (set by gameobject light in void start)
|
||||
private float maxIntensity;
|
||||
public float minIntensity = 0.5f;
|
||||
|
||||
//intervals between flickering light on/off & amount of times to flicker to simulate "malfunctioning"
|
||||
private int burstAmount;
|
||||
private int burst = 3;
|
||||
private float burstInterval = 0.2f;
|
||||
|
||||
private float burstTimer;
|
||||
|
||||
[Header("Random Power Loss")]
|
||||
public bool PowerLossEnable;
|
||||
public ParticleSystem sparks;
|
||||
|
||||
private Coroutine flickerSpotlightCoroutine;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//check if there is a light
|
||||
if (spotLight == null)
|
||||
{
|
||||
//attempt to get light transform if none is defined
|
||||
spotLight = GetComponent<Light>();
|
||||
{
|
||||
//disable script if nothing is found
|
||||
if (!spotLight)
|
||||
{
|
||||
Debug.LogError("No Light Source Detected, Disabling Script: " + transform.name);
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flickerSpotlightCoroutine = StartCoroutine(flickerSpotLight());
|
||||
}
|
||||
|
||||
IEnumerator flickerSpotLight()
|
||||
{
|
||||
//initial random values to base flickering off
|
||||
burstAmount = Random.Range(0, burst);
|
||||
maxIntensity = spotLight.intensity;
|
||||
burstTimer = Random.Range(flickerInterval / 2f, flickerInterval);
|
||||
float minIntensityVariation = minIntensity;
|
||||
float maxIntensityVariation = maxIntensity;
|
||||
|
||||
|
||||
//preset clamp values for instantiated material emission color to usuable values and get material.
|
||||
float minIntensityEmission = minIntensity / maxIntensity;
|
||||
|
||||
//run indefinetely
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(burstTimer);
|
||||
|
||||
//run this x times based on random burst amount, each burst randomises some slight intensity and intervals
|
||||
for (int i = 0; i < burstAmount; i++)
|
||||
{
|
||||
|
||||
spotLight.intensity = minIntensityVariation;
|
||||
yield return new WaitForSeconds(Random.Range(burstInterval * .1f, burstInterval * 1.5f));
|
||||
spotLight.intensity = maxIntensity;
|
||||
yield return new WaitForSeconds(Random.Range(burstInterval * .1f, burstInterval));
|
||||
minIntensityVariation = Random.Range(minIntensity, minIntensity * 1.2f);
|
||||
|
||||
minIntensityEmission = minIntensityVariation / maxIntensity;
|
||||
|
||||
}
|
||||
|
||||
//get new random ranges for next burst, flicker interval and reset light to original values
|
||||
burstAmount = Random.Range(0, burst);
|
||||
burstTimer = Random.Range(flickerInterval * 0.8f, flickerInterval * 1.1f);
|
||||
spotLight.intensity = maxIntensity;
|
||||
|
||||
int powerCheck = Random.Range(1, 10);
|
||||
if (PowerLossEnable && powerCheck == 1)
|
||||
{
|
||||
spotLight.intensity = 0;
|
||||
if (sparks)
|
||||
{
|
||||
ParticleSystem ps = (ParticleSystem)Instantiate(sparks, spotLight.transform.position, spotLight.transform.rotation);
|
||||
Destroy(ps.gameObject, ps.main.duration * 1.5f);
|
||||
}
|
||||
yield return new WaitForSeconds(Random.Range(flickerInterval, flickerInterval * 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//stops coroutine if disabled in scene
|
||||
void OnDisable()
|
||||
{
|
||||
if (flickerSpotlightCoroutine != null)
|
||||
{
|
||||
StopCoroutine(flickerSpotlightCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c06aa8d4a63c3647a8494ca4e043734
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TeaCupController : MonoBehaviour
|
||||
{
|
||||
public GameObject platform;
|
||||
public GameObject teaPot;
|
||||
public Transform[] teaCups;
|
||||
|
||||
[Range(-60,60)]
|
||||
public float rideSpeed = 15.0f;
|
||||
void Update()
|
||||
{
|
||||
//main platform rotation speed
|
||||
platform.transform.Rotate(Vector3.up * rideSpeed * Time.deltaTime);
|
||||
|
||||
//centre ornament (teapot) rotation speed
|
||||
teaPot.transform.Rotate(Vector3.down * (rideSpeed*0.5f) * Time.deltaTime);
|
||||
|
||||
//tea cup rotation's in relation to set ride speed
|
||||
foreach (Transform teacup in teaCups)
|
||||
{
|
||||
teacup.Rotate(Vector3.up * (rideSpeed * 1.5f ) * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c38a6e756266976428febbbe1cc6df26
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user