added animation package and made small changes
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ParticlePlexusDemo_CameraRig : MonoBehaviour
|
||||
{
|
||||
public Transform pivot;
|
||||
Vector3 targetRotation;
|
||||
|
||||
[Range(0.0f, 90.0f)]
|
||||
public float rotationLimit = 90.0f;
|
||||
|
||||
public float rotationSpeed = 2.0f;
|
||||
public float rotationLerpSpeed = 4.0f;
|
||||
|
||||
Vector3 startRotation;
|
||||
|
||||
void Start()
|
||||
{
|
||||
startRotation = pivot.localEulerAngles;
|
||||
targetRotation = startRotation;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float horizontal = Input.GetAxis("Horizontal");
|
||||
float vertical = Input.GetAxis("Vertical");
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
targetRotation = startRotation;
|
||||
}
|
||||
|
||||
horizontal *= rotationSpeed;
|
||||
vertical *= rotationSpeed;
|
||||
|
||||
targetRotation.y += horizontal;
|
||||
targetRotation.x += vertical;
|
||||
|
||||
targetRotation.x = Mathf.Clamp(targetRotation.x, -rotationLimit, rotationLimit);
|
||||
targetRotation.y = Mathf.Clamp(targetRotation.y, -rotationLimit, rotationLimit);
|
||||
|
||||
Vector3 currentRotation = pivot.localEulerAngles;
|
||||
|
||||
currentRotation.x = Mathf.LerpAngle(currentRotation.x, targetRotation.x, Time.deltaTime * rotationLerpSpeed);
|
||||
currentRotation.y = Mathf.LerpAngle(currentRotation.y, targetRotation.y, Time.deltaTime * rotationLerpSpeed);
|
||||
|
||||
pivot.localEulerAngles = currentRotation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c45c745708239bb4faf150bbfcddd20b
|
||||
timeCreated: 1508405059
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user