add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69b1e98ba65b25a42b8fbb6196c26588
|
||||
folderAsset: yes
|
||||
timeCreated: 1576722244
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class cameraEffect : MonoBehaviour
|
||||
{
|
||||
public bool useRenderEffect = true;
|
||||
|
||||
public virtual void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3727478154588d43a905558c8995957
|
||||
timeCreated: 1576378337
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/cameraEffect.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,293 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class cameraEffectSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cameraEffectEnabled = true;
|
||||
|
||||
public bool renderEffectActive = true;
|
||||
|
||||
public bool startWithCameraEffectActive;
|
||||
|
||||
public bool cameraEffectChangeDisabled;
|
||||
|
||||
public int currentCameraEffectIndex;
|
||||
|
||||
[Space]
|
||||
[Header ("Extra Cameras Effect")]
|
||||
[Space]
|
||||
|
||||
public bool renderExtraCameras;
|
||||
|
||||
public List<extraCameraEffectSystem> extraCameraEffectSystemList = new List<extraCameraEffectSystem> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool cameraEffectActive;
|
||||
public cameraEffect currentCameraEffect;
|
||||
|
||||
[Space]
|
||||
[Header ("Camera Effect Info List")]
|
||||
[Space]
|
||||
|
||||
public List<cameraEffectInfo> cameraEffectInfoList = new List<cameraEffectInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
bool cameraEffectAtStartConfigured;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (startWithCameraEffectActive) {
|
||||
setCameraEffectActiveState (true);
|
||||
} else {
|
||||
this.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRenderImage (RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
if (!renderEffectActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cameraEffectActive && currentCameraEffect != null && currentCameraEffect.useRenderEffect) {
|
||||
if (mainCamera == null) {
|
||||
mainCamera = Camera.main;
|
||||
}
|
||||
|
||||
currentCameraEffect.renderEffect (source, destination, mainCamera);
|
||||
}
|
||||
}
|
||||
|
||||
public void extraRenderImage (RenderTexture source, RenderTexture destination, Camera currentCamera)
|
||||
{
|
||||
if (!renderEffectActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cameraEffectActive && currentCameraEffect != null && currentCameraEffect.useRenderEffect) {
|
||||
currentCameraEffect.renderEffect (source, destination, currentCamera);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCameraEffectByName (string cameraStateName)
|
||||
{
|
||||
int cameraEffectIndex = cameraEffectInfoList.FindIndex (a => a.Name == cameraStateName);
|
||||
|
||||
if (cameraEffectIndex > -1) {
|
||||
currentCameraEffectIndex = cameraEffectIndex;
|
||||
|
||||
setCameraEffectActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMainCameraEffectByName (string cameraStateName)
|
||||
{
|
||||
int cameraEffectIndex = cameraEffectInfoList.FindIndex (a => a.Name == cameraStateName);
|
||||
|
||||
if (cameraEffectIndex > -1) {
|
||||
currentCameraEffectIndex = cameraEffectIndex;
|
||||
|
||||
for (int i = 0; i < cameraEffectInfoList.Count; i++) {
|
||||
if (currentCameraEffectIndex == i) {
|
||||
cameraEffectInfoList [i].activeAsMainCameraEffect = true;
|
||||
} else {
|
||||
cameraEffectInfoList [i].activeAsMainCameraEffect = false;
|
||||
}
|
||||
}
|
||||
|
||||
setCameraEffectActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableMainCameraEffectActiveState (string cameraStateName)
|
||||
{
|
||||
int cameraEffectIndex = cameraEffectInfoList.FindIndex (a => a.Name == cameraStateName);
|
||||
|
||||
if (cameraEffectIndex > -1) {
|
||||
currentCameraEffectIndex = cameraEffectIndex;
|
||||
|
||||
cameraEffectInfoList [currentCameraEffectIndex].activeAsMainCameraEffect = false;
|
||||
|
||||
setCameraEffectActiveState (false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIfCurrentCameraEffectRemainActive (bool state)
|
||||
{
|
||||
if (state) {
|
||||
checkIfMainCameraEffectsAreActive ();
|
||||
} else {
|
||||
if (cameraEffectActive) {
|
||||
setCameraEffectActiveState (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfMainCameraEffectsAreActive ()
|
||||
{
|
||||
for (int i = 0; i < cameraEffectInfoList.Count; i++) {
|
||||
if (cameraEffectInfoList [i].activeAsMainCameraEffect) {
|
||||
print ("main camera effect active " + cameraEffectInfoList [i].Name);
|
||||
|
||||
cameraEffectActive = true;
|
||||
currentCameraEffectIndex = i;
|
||||
|
||||
setCameraEffectActiveState (true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool canUseCameraEffect ()
|
||||
{
|
||||
if (!cameraEffectEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cameraEffectChangeDisabled && (!startWithCameraEffectActive || cameraEffectAtStartConfigured)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void enableOrDisableCameraEffectActive ()
|
||||
{
|
||||
setCameraEffectActiveState (!cameraEffectActive);
|
||||
}
|
||||
|
||||
public void setCameraEffectActiveState (bool state)
|
||||
{
|
||||
if (!canUseCameraEffect ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (startWithCameraEffectActive) {
|
||||
cameraEffectAtStartConfigured = true;
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
for (int i = 0; i < cameraEffectInfoList.Count; i++) {
|
||||
if (cameraEffectInfoList [i].activeAsMainCameraEffect) {
|
||||
print ("main camera effect active " + cameraEffectInfoList [i].Name);
|
||||
|
||||
cameraEffectActive = true;
|
||||
currentCameraEffectIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cameraEffectActive = state;
|
||||
|
||||
this.enabled = cameraEffectActive;
|
||||
|
||||
if (cameraEffectActive) {
|
||||
currentCameraEffect = cameraEffectInfoList [currentCameraEffectIndex].mainCameraEffect;
|
||||
|
||||
cameraEffectInfoList [currentCameraEffectIndex].eventToEnableEffect.Invoke ();
|
||||
|
||||
} else {
|
||||
cameraEffectInfoList [currentCameraEffectIndex].eventToDisableEffect.Invoke ();
|
||||
}
|
||||
|
||||
if (renderExtraCameras) {
|
||||
for (int i = 0; i < extraCameraEffectSystemList.Count; i++) {
|
||||
extraCameraEffectSystemList [i].enabled = cameraEffectActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentCameraEffect (cameraEffect newCameraEffect)
|
||||
{
|
||||
currentCameraEffect = newCameraEffect;
|
||||
}
|
||||
|
||||
public void setNextCameraEffect ()
|
||||
{
|
||||
if (!canUseCameraEffect ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
cameraEffectInfoList [currentCameraEffectIndex].eventToDisableEffect.Invoke ();
|
||||
|
||||
currentCameraEffectIndex++;
|
||||
|
||||
if (currentCameraEffectIndex >= cameraEffectInfoList.Count) {
|
||||
currentCameraEffectIndex = 0;
|
||||
}
|
||||
|
||||
currentCameraEffect = cameraEffectInfoList [currentCameraEffectIndex].mainCameraEffect;
|
||||
|
||||
cameraEffectInfoList [currentCameraEffectIndex].eventToEnableEffect.Invoke ();
|
||||
|
||||
if (!cameraEffectActive) {
|
||||
setCameraEffectActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPreviousCameraEffect ()
|
||||
{
|
||||
if (!canUseCameraEffect ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
cameraEffectInfoList [currentCameraEffectIndex].eventToDisableEffect.Invoke ();
|
||||
|
||||
currentCameraEffectIndex--;
|
||||
|
||||
if (currentCameraEffectIndex < 0) {
|
||||
currentCameraEffectIndex = cameraEffectInfoList.Count - 1;
|
||||
}
|
||||
|
||||
currentCameraEffect = cameraEffectInfoList [currentCameraEffectIndex].mainCameraEffect;
|
||||
|
||||
cameraEffectInfoList [currentCameraEffectIndex].eventToEnableEffect.Invoke ();
|
||||
|
||||
if (!cameraEffectActive) {
|
||||
setCameraEffectActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void inputSetNextCameraEffect ()
|
||||
{
|
||||
setNextCameraEffect ();
|
||||
}
|
||||
|
||||
public void inputSetPreviousCameraEffect ()
|
||||
{
|
||||
setPreviousCameraEffect ();
|
||||
}
|
||||
|
||||
public void inputEnableOrDisableCameraEffectActive ()
|
||||
{
|
||||
enableOrDisableCameraEffectActive ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class cameraEffectInfo
|
||||
{
|
||||
public string Name;
|
||||
public bool activeAsMainCameraEffect;
|
||||
public cameraEffect mainCameraEffect;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToEnableEffect;
|
||||
public UnityEvent eventToDisableEffect;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fbc8a24b8590ba41b6cca3145278da4
|
||||
timeCreated: 1576370101
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/cameraEffectSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class customCameraEffect : cameraEffect
|
||||
{
|
||||
public Material mainMaterial;
|
||||
|
||||
public bool useReleaseMethodEnabled;
|
||||
|
||||
public override void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
|
||||
{
|
||||
if (useReleaseMethodEnabled) {
|
||||
var temporaryTexture = RenderTexture.GetTemporary (source.width, source.height);
|
||||
Graphics.Blit (source, temporaryTexture, mainMaterial, 0);
|
||||
Graphics.Blit (temporaryTexture, destination, mainMaterial, 1);
|
||||
RenderTexture.ReleaseTemporary (temporaryTexture);
|
||||
} else {
|
||||
Graphics.Blit (source, destination, mainMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80616fc2119ddf94e91826771009f799
|
||||
timeCreated: 1581232009
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/customCameraEffect.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class extraCameraEffectSystem : MonoBehaviour
|
||||
{
|
||||
public cameraEffectSystem maincameraEffectSystem;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
private void OnRenderImage (RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
if (!maincameraEffectSystem.renderEffectActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainCamera == null) {
|
||||
mainCamera = Camera.main;
|
||||
}
|
||||
|
||||
if (!mainCamera.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
maincameraEffectSystem.extraRenderImage (source, destination, mainCamera);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0f54290bb41dc248a2513912a7ac203
|
||||
timeCreated: 1581697643
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/extraCameraEffectSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,395 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class photoModeSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool photoModeEnabled = true;
|
||||
|
||||
public float rotationSpeed;
|
||||
|
||||
public float smoothCameraRotationSpeedVertical;
|
||||
public float smoothCameraRotationSpeedHorizontal;
|
||||
|
||||
public Vector2 clampTiltX;
|
||||
|
||||
public float movementSpeed;
|
||||
|
||||
public float sidesRotationSpeed = 1;
|
||||
|
||||
public bool clampCameraDistance;
|
||||
public float maxCameraRadius;
|
||||
|
||||
public bool setCustomTimeScale;
|
||||
public float customTimeScale;
|
||||
|
||||
public bool freezeAllCharactersOnScene;
|
||||
|
||||
public bool canUseTurboEnabled = true;
|
||||
public float turboSpeedMultiplier = 2;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnPhotoModeActive;
|
||||
public UnityEvent eventOnPhotoModeDeactive;
|
||||
|
||||
public UnityEvent eventOnTakePhoto;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public Vector2 movementAxisValues;
|
||||
public Vector2 mouseAxisValues;
|
||||
|
||||
public Vector2 currentLookAngle;
|
||||
|
||||
public bool photoModeInputActive;
|
||||
|
||||
public bool photoModeActive;
|
||||
|
||||
public bool turboActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Component Elements")]
|
||||
[Space]
|
||||
|
||||
public Transform mainTransform;
|
||||
public Transform pivotTransform;
|
||||
|
||||
public Transform mainCameraTransform;
|
||||
|
||||
public playerInputManager playerInput;
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
public timeBullet mainTimeBullet;
|
||||
public menuPause pauseManager;
|
||||
|
||||
Transform previousMainCameraParent;
|
||||
|
||||
Quaternion currentPivotRotation;
|
||||
float currentCameraUpRotation;
|
||||
|
||||
Vector3 moveInput;
|
||||
|
||||
bool movingCameraUp;
|
||||
bool movingCameraDown;
|
||||
bool rotatingCameraToRight;
|
||||
bool rotatingCameraToLeft;
|
||||
|
||||
Vector3 lastCameraPosition;
|
||||
|
||||
bool cameraRotationActive = true;
|
||||
|
||||
bool resetingCamera;
|
||||
|
||||
float previosScaleTime;
|
||||
Coroutine resetCameraPositionCoroutine;
|
||||
|
||||
Coroutine mainUpdateCoroutine;
|
||||
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (mainUpdateCoroutine != null) {
|
||||
StopCoroutine (mainUpdateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForSeconds (0.00001f);
|
||||
|
||||
while (true) {
|
||||
|
||||
// void Update ()
|
||||
// {
|
||||
if (photoModeActive && photoModeInputActive) {
|
||||
movementAxisValues = playerInput.getPlayerRawMovementAxisWithoutCheckingEnabled ();
|
||||
|
||||
mouseAxisValues = playerInput.getPlayerMouseAxis ();
|
||||
|
||||
//get the look angle value
|
||||
if (cameraRotationActive) {
|
||||
currentLookAngle.x = mouseAxisValues.x * rotationSpeed;
|
||||
currentLookAngle.y -= mouseAxisValues.y * rotationSpeed;
|
||||
}
|
||||
|
||||
//clamp these values to limit the camera rotation
|
||||
currentLookAngle.y = Mathf.Clamp (currentLookAngle.y, -clampTiltX.x, clampTiltX.y);
|
||||
|
||||
//set every angle in the camera and the pivot
|
||||
currentPivotRotation = Quaternion.Euler (currentLookAngle.y, 0, 0);
|
||||
|
||||
pivotTransform.localRotation = Quaternion.Slerp (pivotTransform.localRotation, currentPivotRotation, smoothCameraRotationSpeedVertical * Time.unscaledDeltaTime);
|
||||
|
||||
currentCameraUpRotation = Mathf.Lerp (currentCameraUpRotation, currentLookAngle.x, smoothCameraRotationSpeedHorizontal * Time.unscaledDeltaTime);
|
||||
|
||||
mainTransform.Rotate (0, currentCameraUpRotation, 0);
|
||||
|
||||
if (rotatingCameraToRight) {
|
||||
mainTransform.Rotate (0, 0, -sidesRotationSpeed);
|
||||
|
||||
rotatingCameraToRight = false;
|
||||
}
|
||||
|
||||
if (rotatingCameraToLeft) {
|
||||
mainTransform.Rotate (0, 0, sidesRotationSpeed);
|
||||
|
||||
rotatingCameraToLeft = false;
|
||||
}
|
||||
|
||||
float currentSpeed = movementSpeed;
|
||||
|
||||
if (turboActive) {
|
||||
currentSpeed *= turboSpeedMultiplier;
|
||||
}
|
||||
|
||||
moveInput = (movementAxisValues.y * pivotTransform.forward + movementAxisValues.x * pivotTransform.right) * currentSpeed;
|
||||
|
||||
if (movingCameraUp) {
|
||||
moveInput += Vector3.up * currentSpeed;
|
||||
|
||||
movingCameraUp = false;
|
||||
}
|
||||
|
||||
if (movingCameraDown) {
|
||||
moveInput -= Vector3.up * currentSpeed;
|
||||
|
||||
movingCameraDown = false;
|
||||
}
|
||||
|
||||
mainTransform.position += (moveInput * Time.unscaledDeltaTime);
|
||||
|
||||
if (clampCameraDistance) {
|
||||
|
||||
Vector3 newLocation = mainTransform.position;
|
||||
|
||||
Vector3 centerPosition = lastCameraPosition;
|
||||
float distance = GKC_Utils.distance (newLocation, centerPosition);
|
||||
|
||||
if (distance > maxCameraRadius) {
|
||||
Vector3 fromOriginToObject = newLocation - centerPosition;
|
||||
fromOriginToObject *= maxCameraRadius / distance;
|
||||
newLocation = centerPosition + fromOriginToObject;
|
||||
}
|
||||
|
||||
mainTransform.position = newLocation;
|
||||
}
|
||||
}
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPhotoModeActiveState (bool state)
|
||||
{
|
||||
if (state == photoModeActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resetingCamera) {
|
||||
return;
|
||||
}
|
||||
|
||||
photoModeActive = state;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
if (photoModeActive) {
|
||||
mainUpdateCoroutine = StartCoroutine (updateCoroutine ());
|
||||
}
|
||||
|
||||
if (setCustomTimeScale) {
|
||||
if (photoModeActive) {
|
||||
previosScaleTime = Time.timeScale;
|
||||
|
||||
mainTimeBullet.setTimeValues (true, customTimeScale);
|
||||
|
||||
pauseManager.setTimeScale (customTimeScale);
|
||||
|
||||
} else {
|
||||
if (previosScaleTime < 1) {
|
||||
mainTimeBullet.setTimeValues (true, previosScaleTime);
|
||||
|
||||
pauseManager.setTimeScale (previosScaleTime);
|
||||
} else {
|
||||
mainTimeBullet.disableTimeBullet ();
|
||||
|
||||
pauseManager.setTimeScale (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (freezeAllCharactersOnScene) {
|
||||
GKC_Utils.pauseOrResumeAllCharactersScene (state);
|
||||
}
|
||||
|
||||
currentLookAngle = Vector2.zero;
|
||||
|
||||
if (photoModeActive) {
|
||||
eventOnPhotoModeActive.Invoke ();
|
||||
|
||||
movementAxisValues = Vector2.zero;
|
||||
mouseAxisValues = Vector2.zero;
|
||||
|
||||
lastCameraPosition = mainCameraTransform.position;
|
||||
|
||||
previousMainCameraParent = mainCameraTransform.parent;
|
||||
|
||||
mainTransform.position = mainCameraTransform.position;
|
||||
|
||||
mainTransform.rotation = mainPlayerCamera.transform.rotation;
|
||||
|
||||
mainTransform.eulerAngles = new Vector3 (mainTransform.eulerAngles.x, mainCameraTransform.eulerAngles.y, mainTransform.eulerAngles.z);
|
||||
|
||||
pivotTransform.rotation = mainCameraTransform.rotation;
|
||||
pivotTransform.localEulerAngles = new Vector3 (pivotTransform.localEulerAngles.x, 0, 0);
|
||||
|
||||
currentLookAngle.y = pivotTransform.localEulerAngles.x;
|
||||
|
||||
if (currentLookAngle.y > 180) {
|
||||
currentLookAngle.y -= 360;
|
||||
}
|
||||
|
||||
mainCameraTransform.SetParent (pivotTransform);
|
||||
|
||||
photoModeInputActive = true;
|
||||
} else {
|
||||
photoModeInputActive = false;
|
||||
|
||||
resetCameraPosition ();
|
||||
}
|
||||
|
||||
turboActive = false;
|
||||
}
|
||||
|
||||
public void enableOrDisablePhotoMode ()
|
||||
{
|
||||
setPhotoModeActiveState (!photoModeActive);
|
||||
}
|
||||
|
||||
public void takePhoto ()
|
||||
{
|
||||
eventOnTakePhoto.Invoke ();
|
||||
}
|
||||
|
||||
public void resetCameraPosition ()
|
||||
{
|
||||
if (resetCameraPositionCoroutine != null) {
|
||||
StopCoroutine (resetCameraPositionCoroutine);
|
||||
}
|
||||
|
||||
resetCameraPositionCoroutine = StartCoroutine (resetCameraCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator resetCameraCoroutine ()
|
||||
{
|
||||
setCameraDirection ();
|
||||
|
||||
if (previousMainCameraParent) {
|
||||
resetingCamera = true;
|
||||
|
||||
mainCameraTransform.SetParent (previousMainCameraParent);
|
||||
|
||||
Vector3 worldTargetPosition = previousMainCameraParent.position;
|
||||
|
||||
float dist = GKC_Utils.distance (mainCameraTransform.position, worldTargetPosition);
|
||||
|
||||
float duration = dist / movementSpeed;
|
||||
|
||||
float t = 0;
|
||||
|
||||
while ((t < 1 && (mainCameraTransform.localPosition != Vector3.zero || mainCameraTransform.localRotation != Quaternion.identity))) {
|
||||
t += Time.unscaledDeltaTime / duration;
|
||||
|
||||
mainCameraTransform.localPosition = Vector3.Lerp (mainCameraTransform.localPosition, Vector3.zero, t);
|
||||
mainCameraTransform.localRotation = Quaternion.Lerp (mainCameraTransform.localRotation, Quaternion.identity, t);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
resetingCamera = false;
|
||||
}
|
||||
|
||||
eventOnPhotoModeDeactive.Invoke ();
|
||||
}
|
||||
|
||||
public void setCameraDirection ()
|
||||
{
|
||||
if (mainPlayerCamera.isUsingRegularGravity ()) {
|
||||
mainPlayerCamera.transform.eulerAngles = (mainPlayerCamera.transform.up * mainTransform.eulerAngles.y);
|
||||
} else {
|
||||
float angleToRotate = Vector3.SignedAngle (mainPlayerCamera.transform.forward, mainTransform.forward, mainPlayerCamera.transform.up);
|
||||
|
||||
mainPlayerCamera.transform.Rotate (0, angleToRotate, 0);
|
||||
}
|
||||
|
||||
Quaternion newCameraRotation = pivotTransform.localRotation;
|
||||
|
||||
mainPlayerCamera.getPivotCameraTransform ().localRotation = newCameraRotation;
|
||||
|
||||
float newLookAngleValue = newCameraRotation.eulerAngles.x;
|
||||
|
||||
if (newLookAngleValue > 180) {
|
||||
newLookAngleValue -= 360;
|
||||
}
|
||||
|
||||
mainPlayerCamera.setLookAngleValue (new Vector2 (0, newLookAngleValue));
|
||||
}
|
||||
|
||||
|
||||
public void inputTakePhoto ()
|
||||
{
|
||||
if (photoModeActive) {
|
||||
takePhoto ();
|
||||
}
|
||||
}
|
||||
|
||||
public void inputToogleCameraRotation ()
|
||||
{
|
||||
if (photoModeActive) {
|
||||
cameraRotationActive = !cameraRotationActive;
|
||||
}
|
||||
}
|
||||
|
||||
public void inputEnableOrDisablePhotoMode ()
|
||||
{
|
||||
enableOrDisablePhotoMode ();
|
||||
}
|
||||
|
||||
public void inputSetTurboMode (bool state)
|
||||
{
|
||||
if (photoModeActive) {
|
||||
if (canUseTurboEnabled) {
|
||||
turboActive = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputMoveCameraUp ()
|
||||
{
|
||||
movingCameraUp = true;
|
||||
}
|
||||
|
||||
public void inputMoveCameraDown ()
|
||||
{
|
||||
movingCameraDown = true;
|
||||
}
|
||||
|
||||
public void inputRotategCameraToRight ()
|
||||
{
|
||||
rotatingCameraToRight = true;
|
||||
}
|
||||
|
||||
public void inputRotateCameraToLeft ()
|
||||
{
|
||||
rotatingCameraToLeft = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e57019b7baed8c4dba40c93a55fe075
|
||||
timeCreated: 1576284117
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/photoModeSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class pixelCameraEffect : cameraEffect
|
||||
{
|
||||
public Shader mainShader;
|
||||
|
||||
public bool useEffectColor;
|
||||
public Color effectColor = Color.white;
|
||||
|
||||
public string blockCountName = "BlockCount";
|
||||
public string blockSizeName = "BlockSize";
|
||||
public string colorName = "_TintColor";
|
||||
|
||||
[Range (64.0f, 1024.0f)] public float BlockCount = 128;
|
||||
Material mainMaterial;
|
||||
|
||||
int blockCountID = -1;
|
||||
int blockSizeID = -1;
|
||||
int colorID = -1;
|
||||
|
||||
public override void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
|
||||
{
|
||||
float k = mainCamera.aspect;
|
||||
Vector2 count = new Vector2 (BlockCount, BlockCount / k);
|
||||
Vector2 size = new Vector2 (1.0f / count.x, 1.0f / count.y);
|
||||
|
||||
setMaterial ();
|
||||
|
||||
if (blockCountID == -1) {
|
||||
blockCountID = Shader.PropertyToID (blockCountName);
|
||||
}
|
||||
|
||||
if (blockSizeID == -1) {
|
||||
blockSizeID = Shader.PropertyToID (blockSizeName);
|
||||
}
|
||||
|
||||
if (colorID == -1) {
|
||||
colorID = Shader.PropertyToID (colorName);
|
||||
}
|
||||
|
||||
mainMaterial.SetVector (blockCountID, count);
|
||||
mainMaterial.SetVector (blockSizeID, size);
|
||||
|
||||
if (useEffectColor) {
|
||||
mainMaterial.SetColor (colorID, effectColor);
|
||||
}
|
||||
|
||||
Graphics.Blit (source, destination, mainMaterial);
|
||||
}
|
||||
|
||||
public void setMaterial ()
|
||||
{
|
||||
if (mainMaterial == null) {
|
||||
mainMaterial = new Material (mainShader);
|
||||
mainMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9756f6f9a410f1f458a706803dcbbeb6
|
||||
timeCreated: 1576377887
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/pixelCameraEffect.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class solidCameraEffect : cameraEffect
|
||||
{
|
||||
public Shader mainShader;
|
||||
|
||||
public Color regularColor = Color.white;
|
||||
|
||||
public bool useEffectColor;
|
||||
public Color effectColor = Color.white;
|
||||
|
||||
public Texture2D mainTexture;
|
||||
|
||||
public string blockCountName = "BlockCount";
|
||||
public string blockSizeName = "BlockSize";
|
||||
public string tintColorName = "_TintColor";
|
||||
public string sprTexName = "_SprTex";
|
||||
public string colorName = "_Color";
|
||||
|
||||
Material mainMaterial;
|
||||
|
||||
int blockCountID = -1;
|
||||
int blockSizeID = -1;
|
||||
int tintColorID = -1;
|
||||
int sprTexID = -1;
|
||||
int colorID = -1;
|
||||
|
||||
public override void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
|
||||
{
|
||||
float w = mainCamera.pixelWidth;
|
||||
float h = mainCamera.pixelHeight;
|
||||
Vector2 count = new Vector2 (w / mainTexture.height, h / mainTexture.height);
|
||||
Vector2 size = new Vector2 (1.0f / count.x, 1.0f / count.y);
|
||||
|
||||
setMaterial ();
|
||||
|
||||
if (blockCountID == -1) {
|
||||
blockCountID = Shader.PropertyToID (blockCountName);
|
||||
}
|
||||
|
||||
if (blockSizeID == -1) {
|
||||
blockSizeID = Shader.PropertyToID (blockSizeName);
|
||||
}
|
||||
|
||||
if (tintColorID == -1) {
|
||||
tintColorID = Shader.PropertyToID (tintColorName);
|
||||
}
|
||||
|
||||
if (sprTexID == -1) {
|
||||
sprTexID = Shader.PropertyToID (sprTexName);
|
||||
}
|
||||
|
||||
if (colorID == -1) {
|
||||
colorID = Shader.PropertyToID (colorName);
|
||||
}
|
||||
|
||||
mainMaterial.SetVector (blockCountID, count);
|
||||
mainMaterial.SetVector (blockSizeID, size);
|
||||
mainMaterial.SetColor (colorID, regularColor);
|
||||
mainMaterial.SetTexture (sprTexID, mainTexture);
|
||||
|
||||
if (useEffectColor) {
|
||||
mainMaterial.SetColor (tintColorID, effectColor);
|
||||
}
|
||||
|
||||
Graphics.Blit (source, destination, mainMaterial);
|
||||
}
|
||||
|
||||
public void setMaterial ()
|
||||
{
|
||||
if (mainMaterial == null) {
|
||||
mainMaterial = new Material (mainShader);
|
||||
mainMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b99c8075436e0046bb43ed1da435316
|
||||
timeCreated: 1576379118
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/solidCameraEffect.cs
|
||||
uploadId: 814740
|
||||
9
Assets/Game Kit Controller/Scripts/Camera/Captures.meta
Normal file
9
Assets/Game Kit Controller/Scripts/Camera/Captures.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6836db34f3e878e49a2dd54d5395838b
|
||||
folderAsset: yes
|
||||
timeCreated: 1526529289
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,433 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
using System.Linq;
|
||||
|
||||
public class cameraCaptureSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useScreenResolution;
|
||||
public Vector2 captureResolution;
|
||||
|
||||
public Color disableButtonsColor;
|
||||
public Color originalColor;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool galleryOpened;
|
||||
public int currentCaptureIndex;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public ScrollRect captureListScrollRect;
|
||||
public GameObject captureSlotPrefab;
|
||||
public Scrollbar scrollBar;
|
||||
|
||||
public GameObject expandedCaptureMenu;
|
||||
public RawImage expandedCaptureImage;
|
||||
|
||||
public Image expandButton;
|
||||
public Image deleteButton;
|
||||
|
||||
public Camera customCameraForEditorCaptures;
|
||||
|
||||
|
||||
bool useRelativePath;
|
||||
|
||||
string captureFolderName;
|
||||
|
||||
string captureFileName;
|
||||
|
||||
string currentSaveDataPath;
|
||||
bool canDelete;
|
||||
bool canExpand;
|
||||
|
||||
List<captureButtonInfo> captureList = new List<captureButtonInfo> ();
|
||||
int previousCaptureAmountInFolder;
|
||||
const string glyphs = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
bool checkSettingsInitialized;
|
||||
|
||||
gameManager gameSystemManager;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (captureSlotPrefab.activeSelf) {
|
||||
captureSlotPrefab.SetActive (false);
|
||||
}
|
||||
|
||||
changeButtonsColor (false, false);
|
||||
|
||||
if (expandedCaptureMenu.activeSelf) {
|
||||
expandedCaptureMenu.SetActive (false);
|
||||
}
|
||||
|
||||
setMainSettings ();
|
||||
}
|
||||
|
||||
public void setMainSettings ()
|
||||
{
|
||||
bool mainGameManagerLocated = gameSystemManager != null;
|
||||
|
||||
if (!mainGameManagerLocated) {
|
||||
gameSystemManager = gameManager.Instance;
|
||||
|
||||
mainGameManagerLocated = gameSystemManager != null;
|
||||
}
|
||||
|
||||
if (!mainGameManagerLocated) {
|
||||
gameSystemManager = FindObjectOfType<gameManager> ();
|
||||
|
||||
gameSystemManager.getComponentInstanceOnApplicationPlaying ();
|
||||
}
|
||||
|
||||
useRelativePath = gameSystemManager.useRelativePath;
|
||||
|
||||
captureFolderName = gameSystemManager.getSaveCaptureFolder ();
|
||||
|
||||
captureFileName = gameSystemManager.getSaveCaptureFileName ();
|
||||
}
|
||||
|
||||
public void checkSettings ()
|
||||
{
|
||||
if (!checkSettingsInitialized) {
|
||||
currentSaveDataPath = getDataPath ();
|
||||
checkSettingsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCaptures ()
|
||||
{
|
||||
checkSettings ();
|
||||
|
||||
int numberOfFiles = 0;
|
||||
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo (currentSaveDataPath);
|
||||
var fileInfo = dir.GetFiles ().OrderBy (p => p.CreationTime).ToArray ();
|
||||
|
||||
//if the number of pictures has changed, reload these elements
|
||||
if (previousCaptureAmountInFolder != fileInfo.Length) {
|
||||
previousCaptureAmountInFolder = fileInfo.Length;
|
||||
|
||||
for (int i = 0; i < captureList.Count; i++) {
|
||||
Destroy (captureList [i].slotGameObject);
|
||||
}
|
||||
|
||||
captureList.Clear ();
|
||||
|
||||
foreach (FileInfo file in fileInfo) {
|
||||
|
||||
#if !UNITY_WEBPLAYER
|
||||
string currentDataFile = currentSaveDataPath + file.Name;
|
||||
|
||||
if (File.Exists (currentDataFile)) {
|
||||
|
||||
byte[] bytes = File.ReadAllBytes (currentDataFile);
|
||||
|
||||
Texture2D texture = new Texture2D ((int)captureResolution.x, (int)captureResolution.y);
|
||||
|
||||
texture.filterMode = FilterMode.Trilinear;
|
||||
|
||||
texture.LoadImage (bytes);
|
||||
|
||||
addCaptureSlot (numberOfFiles, file.Name);
|
||||
|
||||
captureList [numberOfFiles].capture.texture = texture;
|
||||
|
||||
numberOfFiles++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
captureListScrollRect.verticalNormalizedPosition = 0.5f;
|
||||
scrollBar.value = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void getSaveButtonSelected (Button button)
|
||||
{
|
||||
currentCaptureIndex = -1;
|
||||
|
||||
bool delete = false;
|
||||
bool expand = false;
|
||||
|
||||
for (int i = 0; i < captureList.Count; i++) {
|
||||
if (captureList [i].button == button) {
|
||||
currentCaptureIndex = i;
|
||||
delete = true;
|
||||
expand = true;
|
||||
}
|
||||
}
|
||||
|
||||
changeButtonsColor (delete, expand);
|
||||
}
|
||||
|
||||
public void addCaptureSlot (int index, string fileName)
|
||||
{
|
||||
GameObject newSlotPrefab = (GameObject)Instantiate (captureSlotPrefab, captureSlotPrefab.transform.position,
|
||||
captureSlotPrefab.transform.rotation, captureSlotPrefab.transform.parent);
|
||||
|
||||
if (!newSlotPrefab.activeSelf) {
|
||||
newSlotPrefab.SetActive (true);
|
||||
}
|
||||
|
||||
newSlotPrefab.transform.localScale = Vector3.one;
|
||||
|
||||
newSlotPrefab.name = "Capture Slot " + (index + 1);
|
||||
|
||||
captureSlot newCaptureSlot = newSlotPrefab.GetComponent<captureSlot> ();
|
||||
|
||||
newCaptureSlot.captureInfo.fileName = fileName;
|
||||
|
||||
captureList.Add (newCaptureSlot.captureInfo);
|
||||
}
|
||||
|
||||
public void changeButtonsColor (bool delete, bool expand)
|
||||
{
|
||||
if (delete) {
|
||||
deleteButton.color = originalColor;
|
||||
} else {
|
||||
deleteButton.color = disableButtonsColor;
|
||||
}
|
||||
|
||||
if (expand) {
|
||||
expandButton.color = originalColor;
|
||||
} else {
|
||||
expandButton.color = disableButtonsColor;
|
||||
}
|
||||
|
||||
canDelete = delete;
|
||||
|
||||
canExpand = expand;
|
||||
}
|
||||
|
||||
public void openCaptureGallery ()
|
||||
{
|
||||
openOrCloseCapturesGallery (true);
|
||||
}
|
||||
|
||||
public void closeCaptureGallery ()
|
||||
{
|
||||
openOrCloseCapturesGallery (false);
|
||||
}
|
||||
|
||||
public void openOrCloseCapturesGallery (bool state)
|
||||
{
|
||||
galleryOpened = state;
|
||||
|
||||
if (galleryOpened) {
|
||||
loadCaptures ();
|
||||
} else {
|
||||
changeButtonsColor (false, false);
|
||||
|
||||
expandedCaptureMenu.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
public string getDataPath ()
|
||||
{
|
||||
string dataPath = "";
|
||||
|
||||
if (useRelativePath) {
|
||||
dataPath = captureFolderName;
|
||||
} else {
|
||||
dataPath = Application.persistentDataPath + "/" + captureFolderName;
|
||||
}
|
||||
|
||||
if (!Directory.Exists (dataPath)) {
|
||||
Directory.CreateDirectory (dataPath);
|
||||
}
|
||||
|
||||
dataPath += "/";
|
||||
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public void takeCapture (Camera currentCamera)
|
||||
{
|
||||
checkSettings ();
|
||||
|
||||
// get the camera's render texture
|
||||
RenderTexture previousRenderTexture = currentCamera.targetTexture;
|
||||
|
||||
Vector2 currentResolution = captureResolution;
|
||||
|
||||
if (useScreenResolution) {
|
||||
currentResolution = new Vector2 (Screen.currentResolution.width, Screen.currentResolution.height);
|
||||
}
|
||||
|
||||
currentCamera.targetTexture = new RenderTexture ((int)currentResolution.x, (int)currentResolution.y, 24);
|
||||
|
||||
RenderTexture rendText = RenderTexture.active;
|
||||
RenderTexture.active = currentCamera.targetTexture;
|
||||
|
||||
//render the texture
|
||||
currentCamera.Render ();
|
||||
|
||||
//create a new Texture2D with the camera's texture, using its height and width
|
||||
Texture2D cameraImage = new Texture2D ((int)currentResolution.x, (int)currentResolution.y, TextureFormat.RGB24, false);
|
||||
cameraImage.ReadPixels (new Rect (0, 0, (int)currentResolution.x, (int)currentResolution.y), 0, 0);
|
||||
cameraImage.Apply ();
|
||||
|
||||
RenderTexture.active = rendText;
|
||||
//store the texture into a .PNG file
|
||||
|
||||
#if !UNITY_WEBPLAYER
|
||||
byte[] bytes = cameraImage.EncodeToPNG ();
|
||||
|
||||
int numberOfFiles = 0;
|
||||
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo (currentSaveDataPath);
|
||||
if (dir.Exists) {
|
||||
numberOfFiles = dir.GetFiles ().Length;
|
||||
}
|
||||
|
||||
currentCamera.targetTexture = previousRenderTexture;
|
||||
RenderTexture.active = currentCamera.targetTexture;
|
||||
|
||||
string randomString = "";
|
||||
|
||||
int charAmount = UnityEngine.Random.Range (10, 20); //set those to the minimum and maximum length of your string
|
||||
for (int i = 0; i < charAmount; i++) {
|
||||
randomString += glyphs [UnityEngine.Random.Range (0, glyphs.Length)];
|
||||
}
|
||||
|
||||
if (File.Exists (currentSaveDataPath + captureFileName + "_" + randomString + ".png")) {
|
||||
randomString += glyphs [UnityEngine.Random.Range (0, glyphs.Length)];
|
||||
}
|
||||
//save the encoded image to a file
|
||||
System.IO.File.WriteAllBytes (currentSaveDataPath + (captureFileName + "_" + randomString + ".png"), bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void takeCaptureWithCameraEditor ()
|
||||
{
|
||||
setMainSettings ();
|
||||
|
||||
takeCapture (customCameraForEditorCaptures);
|
||||
}
|
||||
|
||||
public void deleteCapture ()
|
||||
{
|
||||
checkSettings ();
|
||||
|
||||
if (currentCaptureIndex != -1 && canDelete) {
|
||||
|
||||
string fileName = captureList [currentCaptureIndex].fileName;
|
||||
|
||||
if (File.Exists (currentSaveDataPath + fileName)) {
|
||||
File.Delete (currentSaveDataPath + fileName);
|
||||
}
|
||||
|
||||
destroyCaptureSlot (currentCaptureIndex);
|
||||
|
||||
currentCaptureIndex = -1;
|
||||
|
||||
changeButtonsColor (false, false);
|
||||
|
||||
captureListScrollRect.verticalNormalizedPosition = 0.5f;
|
||||
|
||||
scrollBar.value = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteExpandedCapture ()
|
||||
{
|
||||
checkSettings ();
|
||||
|
||||
print (currentCaptureIndex);
|
||||
|
||||
if (currentCaptureIndex != -1) {
|
||||
|
||||
string fileName = captureList [currentCaptureIndex].fileName;
|
||||
|
||||
if (File.Exists (currentSaveDataPath + fileName)) {
|
||||
File.Delete (currentSaveDataPath + fileName);
|
||||
}
|
||||
|
||||
destroyCaptureSlot (currentCaptureIndex);
|
||||
|
||||
if (captureList.Count > 0) {
|
||||
if ((currentCaptureIndex + 1) < captureList.Count) {
|
||||
expandNextCapture ();
|
||||
} else {
|
||||
expandPreviousCapture ();
|
||||
}
|
||||
} else {
|
||||
expandedCaptureMenu.SetActive (false);
|
||||
closeExpandCaptureMenu ();
|
||||
}
|
||||
|
||||
captureListScrollRect.verticalNormalizedPosition = 0.5f;
|
||||
|
||||
scrollBar.value = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void expandCapture ()
|
||||
{
|
||||
if (currentCaptureIndex != -1 && canExpand) {
|
||||
expandedCaptureMenu.SetActive (true);
|
||||
|
||||
expandedCaptureImage.texture = captureList [currentCaptureIndex].capture.texture;
|
||||
}
|
||||
}
|
||||
|
||||
public void expandNextCapture ()
|
||||
{
|
||||
if (galleryOpened) {
|
||||
currentCaptureIndex++;
|
||||
|
||||
if (currentCaptureIndex >= captureList.Count) {
|
||||
currentCaptureIndex = 0;
|
||||
}
|
||||
|
||||
expandedCaptureImage.texture = captureList [currentCaptureIndex].capture.texture;
|
||||
}
|
||||
}
|
||||
|
||||
public void expandPreviousCapture ()
|
||||
{
|
||||
if (galleryOpened) {
|
||||
currentCaptureIndex--;
|
||||
|
||||
if (currentCaptureIndex < 0) {
|
||||
currentCaptureIndex = captureList.Count - 1;
|
||||
}
|
||||
|
||||
expandedCaptureImage.texture = captureList [currentCaptureIndex].capture.texture;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeExpandCaptureMenu ()
|
||||
{
|
||||
changeButtonsColor (false, false);
|
||||
}
|
||||
|
||||
public void destroyCaptureSlot (int slotIndex)
|
||||
{
|
||||
Destroy (captureList [slotIndex].slotGameObject);
|
||||
|
||||
captureList.RemoveAt (slotIndex);
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class captureButtonInfo
|
||||
{
|
||||
public GameObject slotGameObject;
|
||||
public Button button;
|
||||
public RawImage capture;
|
||||
public string fileName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba13183ca4c9840419119ab4d6f0c085
|
||||
timeCreated: 1524526324
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Captures/cameraCaptureSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,348 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class cameraPerspectiveSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public List<GameObject> objectToLookList = new List<GameObject> ();
|
||||
public float maxDistance;
|
||||
public float maxAngle;
|
||||
|
||||
public float proximitySoundRate;
|
||||
public float maxPitchValue = 3;
|
||||
|
||||
public LayerMask layerForUsers;
|
||||
|
||||
public bool activateObjectOnCapture;
|
||||
public List<GameObject> objectToActiveList = new List<GameObject> ();
|
||||
|
||||
public bool disableObjectOnCapture;
|
||||
public List<GameObject> objectToDisableList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Sounds Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useCaptureSound;
|
||||
public AudioClip captureSound;
|
||||
public AudioElement captureAudioElement;
|
||||
|
||||
public bool useProximitySound;
|
||||
public AudioClip proximitySound;
|
||||
public AudioElement proximityAudioElement;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool captureTakenCorrectly;
|
||||
public bool playerInside;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventFunction;
|
||||
public UnityEvent eventFunction = new UnityEvent ();
|
||||
|
||||
[Space]
|
||||
[Header ("Gizmo Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showGizmo;
|
||||
public float gizmoArrowLength = 1;
|
||||
public float gizmoArrowAngle = 20;
|
||||
public Color gizmoArrowColor = Color.white;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform positionToStay;
|
||||
public Transform positionToLook;
|
||||
|
||||
public AudioSource bipAudioSource;
|
||||
public AudioSource captureAudioSource;
|
||||
|
||||
GameObject currentPlayer;
|
||||
smartphoneDevice smartphoneDeviceManager;
|
||||
float lastTimePlayed;
|
||||
float triggerDistance;
|
||||
float distancePercentage = 1;
|
||||
float soundRate;
|
||||
|
||||
Vector3 screenPoint;
|
||||
|
||||
bool usingScreenSpaceCamera;
|
||||
|
||||
bool targetOnScreen;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager;
|
||||
|
||||
float screenWidth;
|
||||
float screenHeight;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
|
||||
private void InitializeAudioElements ()
|
||||
{
|
||||
if (proximitySound != null) {
|
||||
proximityAudioElement.clip = proximitySound;
|
||||
}
|
||||
|
||||
if (bipAudioSource != null) {
|
||||
proximityAudioElement.audioSource = bipAudioSource;
|
||||
}
|
||||
|
||||
if (captureSound != null) {
|
||||
captureAudioElement.clip = captureSound;
|
||||
}
|
||||
|
||||
if (captureAudioSource != null) {
|
||||
captureAudioElement.audioSource = captureAudioSource;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start ()
|
||||
{
|
||||
InitializeAudioElements ();
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (!captureTakenCorrectly) {
|
||||
if (playerInside && useProximitySound) {
|
||||
if (Time.time > lastTimePlayed + soundRate) {
|
||||
float currentDistance = GKC_Utils.distance (currentPlayer.transform.position, positionToStay.position);
|
||||
|
||||
distancePercentage = currentDistance / triggerDistance;
|
||||
|
||||
float pitchValue = 1 + ((1 - distancePercentage) * (maxPitchValue - 1));
|
||||
|
||||
if (pitchValue <= 0) {
|
||||
pitchValue = 0.1f;
|
||||
}
|
||||
|
||||
if (pitchValue > maxPitchValue) {
|
||||
pitchValue = maxPitchValue;
|
||||
}
|
||||
|
||||
bipAudioSource.pitch = pitchValue;
|
||||
|
||||
AudioPlayer.PlayOneShot (proximityAudioElement, gameObject);
|
||||
|
||||
lastTimePlayed = Time.time;
|
||||
|
||||
soundRate = distancePercentage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkCurrentPlayerPosition (Transform playerPosition, Transform cameraTransform, Camera deviceCamera)
|
||||
{
|
||||
if (captureTakenCorrectly) {
|
||||
return;
|
||||
}
|
||||
|
||||
float currentDistance = GKC_Utils.distance (playerPosition.position, positionToStay.position);
|
||||
|
||||
if (currentDistance <= maxDistance) {
|
||||
|
||||
Vector3 targetDir = positionToLook.position - cameraTransform.position;
|
||||
targetDir = targetDir.normalized;
|
||||
|
||||
float dot = Vector3.Dot (targetDir, cameraTransform.forward);
|
||||
float currentAngleZ = Mathf.Acos (dot) * Mathf.Rad2Deg;
|
||||
|
||||
if (Mathf.Abs (currentAngleZ) < maxAngle) {
|
||||
bool allObjectsInCamera = true;
|
||||
|
||||
if (!usingScreenSpaceCamera) {
|
||||
screenWidth = Screen.width;
|
||||
screenHeight = Screen.height;
|
||||
}
|
||||
|
||||
for (int i = 0; i < objectToLookList.Count; i++) {
|
||||
if (usingScreenSpaceCamera) {
|
||||
screenPoint = deviceCamera.WorldToViewportPoint (objectToLookList [i].transform.position);
|
||||
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
|
||||
} else {
|
||||
screenPoint = deviceCamera.WorldToScreenPoint (objectToLookList [i].transform.position);
|
||||
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < screenWidth && screenPoint.y > 0 && screenPoint.y < screenHeight;
|
||||
}
|
||||
|
||||
if (!targetOnScreen) {
|
||||
allObjectsInCamera = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allObjectsInCamera) {
|
||||
playSound ();
|
||||
|
||||
if (activateObjectOnCapture) {
|
||||
for (int i = 0; i < objectToActiveList.Count; i++) {
|
||||
if (!objectToActiveList [i].activeSelf) {
|
||||
objectToActiveList [i].SetActive (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (disableObjectOnCapture) {
|
||||
for (int i = 0; i < objectToDisableList.Count; i++) {
|
||||
if (objectToDisableList [i].activeSelf) {
|
||||
objectToDisableList [i].SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useEventFunction) {
|
||||
if (eventFunction.GetPersistentEventCount () > 0) {
|
||||
eventFunction.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
captureTakenCorrectly = true;
|
||||
|
||||
if (smartphoneDeviceManager != null) {
|
||||
smartphoneDeviceManager.removeCurrentPerspectiveSystem ();
|
||||
}
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("capture done correctly");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void playSound ()
|
||||
{
|
||||
if (useCaptureSound) {
|
||||
GKC_Utils.checkAudioSourcePitch (captureAudioSource);
|
||||
|
||||
AudioPlayer.PlayOneShot (captureAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
//check when the player enters or exits of the trigger in the device
|
||||
void OnTriggerEnter (Collider col)
|
||||
{
|
||||
checkTriggerInfo (col, true);
|
||||
}
|
||||
|
||||
void OnTriggerExit (Collider col)
|
||||
{
|
||||
checkTriggerInfo (col, false);
|
||||
}
|
||||
|
||||
public void checkTriggerInfo (Collider col, bool isEnter)
|
||||
{
|
||||
if ((1 << col.gameObject.layer & layerForUsers.value) == 1 << col.gameObject.layer) {
|
||||
//if the player is entering in the trigger
|
||||
if (isEnter) {
|
||||
if (playerInside) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayer = col.gameObject;
|
||||
|
||||
mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
smartphoneDeviceManager = currentPlayer.GetComponentInChildren<smartphoneDevice> ();
|
||||
|
||||
if (smartphoneDeviceManager == null) {
|
||||
smartphoneDeviceManager = mainPlayerComponentsManager.getPlayerCamera ().gameObject.GetComponentInChildren<smartphoneDevice> ();
|
||||
}
|
||||
|
||||
if (smartphoneDeviceManager != null) {
|
||||
smartphoneDeviceManager.setCurrentPerspectiveSystem (this);
|
||||
}
|
||||
|
||||
usingScreenSpaceCamera = mainPlayerComponentsManager.getPlayerCamera ().isUsingScreenSpaceCamera ();
|
||||
|
||||
playerInside = true;
|
||||
triggerDistance = GKC_Utils.distance (currentPlayer.transform.position, positionToStay.position);
|
||||
bipAudioSource.pitch = 1;
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
|
||||
} else {
|
||||
//if the player is leaving the trigger
|
||||
|
||||
//if the player is the same that was using the device, the device can be used again
|
||||
if (col.gameObject == currentPlayer) {
|
||||
currentPlayer = null;
|
||||
playerInside = false;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
//draw the pivot and the final positions of every door
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
if (positionToStay != null && positionToLook != null) {
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawSphere (positionToStay.position, 0.3f);
|
||||
Gizmos.DrawSphere (positionToLook.position, 0.3f);
|
||||
|
||||
Gizmos.DrawLine (positionToStay.position, positionToLook.position);
|
||||
|
||||
Vector3 direction = positionToLook.position - positionToStay.position;
|
||||
direction = direction / direction.magnitude;
|
||||
float distance = GKC_Utils.distance (positionToLook.position, positionToStay.position);
|
||||
GKC_Utils.drawGizmoArrow (positionToStay.position, direction * distance, gizmoArrowColor, gizmoArrowLength, gizmoArrowAngle);
|
||||
|
||||
positionToLook.rotation = Quaternion.LookRotation (direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca643d6e5129ef3488204dd42db3b54c
|
||||
timeCreated: 1524617233
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Captures/cameraPerspectiveSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class captureSlot : MonoBehaviour {
|
||||
|
||||
public cameraCaptureSystem.captureButtonInfo captureInfo;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 914fc1745b4a8c749ae64b54f449e2eb
|
||||
timeCreated: 1524534914
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Captures/captureSlot.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,97 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class remoteEventOnCameraCaptureSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkObjectFoundOnCaptureEnabled = true;
|
||||
|
||||
public LayerMask layermaskToUse;
|
||||
|
||||
public float maxRaycastDistance = 20;
|
||||
|
||||
public bool sendObjectOnSurfaceDetected;
|
||||
public GameObject objectToSendOnSurfaceDetected;
|
||||
|
||||
[Space]
|
||||
[Header ("Raycast Detection Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useCapsuleRaycast;
|
||||
|
||||
public float capsuleCastRadius;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform cameraTransform;
|
||||
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
RaycastHit[] hits;
|
||||
|
||||
public void checkCapture ()
|
||||
{
|
||||
if (checkObjectFoundOnCaptureEnabled) {
|
||||
if (Physics.Raycast (cameraTransform.position, cameraTransform.forward, out hit, maxRaycastDistance, layermaskToUse)) {
|
||||
if (useCapsuleRaycast) {
|
||||
|
||||
Vector3 currentRayOriginPosition = cameraTransform.position;
|
||||
|
||||
Vector3 currentRayTargetPosition = hit.point;
|
||||
|
||||
float distanceToTarget = GKC_Utils.distance (currentRayOriginPosition, currentRayTargetPosition);
|
||||
Vector3 rayDirection = currentRayOriginPosition - currentRayTargetPosition;
|
||||
rayDirection = rayDirection / rayDirection.magnitude;
|
||||
|
||||
Debug.DrawLine (currentRayTargetPosition, (rayDirection * distanceToTarget) + currentRayTargetPosition, Color.red, 2);
|
||||
|
||||
Vector3 point1 = currentRayOriginPosition - rayDirection * capsuleCastRadius;
|
||||
Vector3 point2 = currentRayTargetPosition + rayDirection * capsuleCastRadius;
|
||||
|
||||
hits = Physics.CapsuleCastAll (point1, point2, capsuleCastRadius, rayDirection, 0, layermaskToUse);
|
||||
|
||||
for (int i = 0; i < hits.Length; i++) {
|
||||
GameObject currentSurfaceGameObjectFound = hits [i].collider.gameObject;
|
||||
|
||||
checkObjectDetected (currentSurfaceGameObjectFound);
|
||||
}
|
||||
} else {
|
||||
checkObjectDetected (hit.collider.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkObjectDetected (GameObject objectDetected)
|
||||
{
|
||||
GameObject character = applyDamage.getCharacterOrVehicle (objectDetected);
|
||||
|
||||
if (character != null) {
|
||||
objectDetected = character;
|
||||
}
|
||||
|
||||
if (objectDetected != null) {
|
||||
|
||||
eventObjectFoundOnCaptureSystem currentEventObjectFoundOnCaptureSystem = objectDetected.GetComponent<eventObjectFoundOnCaptureSystem> ();
|
||||
|
||||
if (currentEventObjectFoundOnCaptureSystem != null) {
|
||||
currentEventObjectFoundOnCaptureSystem.callEventOnCapture ();
|
||||
|
||||
if (sendObjectOnSurfaceDetected) {
|
||||
currentEventObjectFoundOnCaptureSystem.callEventOnCaptureWithGameObject (objectToSendOnSurfaceDetected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewCameraTransform (Transform newCamera)
|
||||
{
|
||||
cameraTransform = newCamera;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9928dabe8e0adf4b92f357a3d6e15cb
|
||||
timeCreated: 1603953704
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Captures/remoteEventOnCameraCaptureSystem.cs
|
||||
uploadId: 814740
|
||||
9
Assets/Game Kit Controller/Scripts/Camera/Cutscene.meta
Normal file
9
Assets/Game Kit Controller/Scripts/Camera/Cutscene.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97c3397a092edfd44b0c91f5b1f22843
|
||||
folderAsset: yes
|
||||
timeCreated: 1538634226
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,807 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Events;
|
||||
using System;
|
||||
|
||||
public class cameraWaypointSystem : MonoBehaviour
|
||||
{
|
||||
public bool cameraWaypointEnabled = true;
|
||||
|
||||
public Transform currentCameraTransform;
|
||||
public List<cameraWaypointInfo> waypointList = new List<cameraWaypointInfo> ();
|
||||
public float waitTimeBetweenPoints;
|
||||
public float movementSpeed;
|
||||
public float rotationSpeed;
|
||||
|
||||
public Transform pointToLook;
|
||||
|
||||
public bool useEventOnEnd;
|
||||
public UnityEvent eventOnEnd;
|
||||
|
||||
public bool showGizmo;
|
||||
public Color gizmoLabelColor = Color.black;
|
||||
public float gizmoRadius;
|
||||
public bool useHandleForWaypoints;
|
||||
public float handleRadius;
|
||||
public Color handleGizmoColor;
|
||||
public bool showWaypointHandles;
|
||||
|
||||
public float currentMovementSpeed;
|
||||
public float currentRotationSpeed;
|
||||
|
||||
public bool useBezierCurve;
|
||||
public BezierSpline spline;
|
||||
public float bezierDuration = 10;
|
||||
public bool useExternalProgress;
|
||||
[NonSerialized]
|
||||
public Func<float> externalProgress;
|
||||
public bool snapCameraToFirstSplinePoint;
|
||||
|
||||
public bool searchPlayerOnSceneIfNotAssigned = true;
|
||||
|
||||
public bool resetCameraPositionOnEnd;
|
||||
public float resetCameraPositionSpeed = 5;
|
||||
|
||||
public bool pausePlayerCameraEnabled;
|
||||
|
||||
public bool useMainCameraTransform;
|
||||
|
||||
public bool setThisTransformAsCameraParent;
|
||||
|
||||
public bool ignoreWaypointOnFreeCamera;
|
||||
public bool ignoreWaypointOnLockedCamera;
|
||||
public bool ignoreWaypointOnFBA;
|
||||
|
||||
|
||||
public bool useEventToStopCutScene;
|
||||
public UnityEvent eventToStopCutscene;
|
||||
|
||||
|
||||
|
||||
bool waypointInProcess;
|
||||
|
||||
bool customTransformToLookActive;
|
||||
Transform customTransformToLook;
|
||||
|
||||
|
||||
Coroutine resetCameraPositionCoroutine;
|
||||
|
||||
float currentWaitTime;
|
||||
Vector3 targetDirection;
|
||||
|
||||
Coroutine movement;
|
||||
Transform currentWaypoint;
|
||||
int currentWaypointIndex;
|
||||
|
||||
int i;
|
||||
|
||||
List<Transform> currentPath = new List<Transform> ();
|
||||
cameraWaypointInfo currentCameraWaypointInfo;
|
||||
|
||||
int previousWaypointIndex;
|
||||
|
||||
Vector3 targetPosition;
|
||||
Quaternion targetRotation;
|
||||
|
||||
GameObject playerCameraGameObject;
|
||||
Transform pivotDirection;
|
||||
|
||||
playerCamera currentPlayerCamera;
|
||||
|
||||
Transform previousCameraParent;
|
||||
|
||||
Vector3 previousCameraPosition;
|
||||
Quaternion previousCameraRotation;
|
||||
|
||||
bool isCameraTypeFree;
|
||||
|
||||
bool isCameraTypeFBA;
|
||||
|
||||
|
||||
public void setCurrentCameraTransform (GameObject cameraGameObject)
|
||||
{
|
||||
if (cameraGameObject == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentCameraTransform = cameraGameObject.transform;
|
||||
|
||||
if (previousCameraParent == null) {
|
||||
previousCameraParent = currentCameraTransform.parent;
|
||||
|
||||
previousCameraPosition = currentCameraTransform.localPosition;
|
||||
previousCameraRotation = currentCameraTransform.localRotation;
|
||||
}
|
||||
}
|
||||
|
||||
public void findPlayerOnScene ()
|
||||
{
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
GameObject currentPlayer = GKC_Utils.findMainPlayerOnScene ();
|
||||
|
||||
setCurrentPlayer (currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject currentPlayer)
|
||||
{
|
||||
if (currentPlayer != null) {
|
||||
playerComponentsManager mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
currentPlayerCamera = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
playerCameraGameObject = currentPlayerCamera.gameObject;
|
||||
|
||||
pivotDirection = currentPlayerCamera.getPivotCameraTransform ();
|
||||
|
||||
isCameraTypeFree = currentPlayerCamera.isCameraTypeFree ();
|
||||
|
||||
isCameraTypeFBA = currentPlayerCamera.isFullBodyAwarenessActive ();
|
||||
|
||||
if (useMainCameraTransform) {
|
||||
if (isCameraTypeFree) {
|
||||
setCurrentCameraTransform (currentPlayerCamera.getCameraTransform ().gameObject);
|
||||
} else {
|
||||
setCurrentCameraTransform (currentPlayerCamera.getCurrentLockedCameraTransform ().gameObject);
|
||||
}
|
||||
} else {
|
||||
setCurrentCameraTransform (currentPlayerCamera.getMainCamera ().gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ignoreWaypointOnCurrentViewResult ()
|
||||
{
|
||||
if (ignoreWaypointOnFreeCamera) {
|
||||
if (isCameraTypeFree) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreWaypointOnLockedCamera) {
|
||||
if (!isCameraTypeFree) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreWaypointOnFBA) {
|
||||
if (isCameraTypeFBA) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//stop the platform coroutine movement and play again
|
||||
public void checkMovementCoroutine (bool play)
|
||||
{
|
||||
if (!cameraWaypointEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ignoreWaypointOnCurrentViewResult ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
stopMoveThroughWayPointsCoroutine ();
|
||||
|
||||
if (play) {
|
||||
if (currentCameraTransform == null) {
|
||||
findPlayerOnScene ();
|
||||
|
||||
if (currentCameraTransform == null) {
|
||||
print ("WARNING: no current camera transform has been assigned on the camera waypoint system." +
|
||||
" Make sure to use a trigger to activate the element or assign the player manually");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentWaypointIndex = 0;
|
||||
|
||||
previousWaypointIndex = -1;
|
||||
|
||||
//if the current path to move has waypoints, then
|
||||
if (currentPath.Count == 0) {
|
||||
for (i = 0; i < waypointList.Count; i++) {
|
||||
currentPath.Add (waypointList [i].waypointTransform);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPath.Count > 0) {
|
||||
if (pausePlayerCameraEnabled) {
|
||||
currentPlayerCamera.pauseOrPlayCamera (false);
|
||||
}
|
||||
|
||||
if (setThisTransformAsCameraParent) {
|
||||
currentCameraTransform.SetParent (transform);
|
||||
}
|
||||
|
||||
if (useBezierCurve) {
|
||||
movement = StartCoroutine (moveAlongBezierCurve ());
|
||||
} else {
|
||||
movement = StartCoroutine (moveAlongWaypoints ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMoveThroughWayPointsCoroutine ()
|
||||
{
|
||||
if (movement != null) {
|
||||
StopCoroutine (movement);
|
||||
}
|
||||
|
||||
waypointInProcess = false;
|
||||
}
|
||||
|
||||
IEnumerator moveAlongWaypoints ()
|
||||
{
|
||||
waypointInProcess = true;
|
||||
|
||||
//move between every waypoint
|
||||
foreach (Transform waypoint in currentPath) {
|
||||
currentWaypoint = waypoint;
|
||||
currentCameraWaypointInfo = waypointList [currentWaypointIndex];
|
||||
|
||||
//wait the amount of time configured
|
||||
if (currentCameraWaypointInfo.useCustomWaitTimeBetweenPoint) {
|
||||
currentWaitTime = currentCameraWaypointInfo.waitTimeBetweenPoints;
|
||||
} else {
|
||||
currentWaitTime = waitTimeBetweenPoints;
|
||||
}
|
||||
|
||||
targetPosition = currentWaypoint.position;
|
||||
targetRotation = currentWaypoint.rotation;
|
||||
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentWaitTime);
|
||||
|
||||
yield return delay;
|
||||
|
||||
//yield return new WaitForSeconds (currentWaitTime);
|
||||
|
||||
if (currentCameraWaypointInfo.useCustomMovementSpeed) {
|
||||
currentMovementSpeed = currentCameraWaypointInfo.movementSpeed;
|
||||
} else {
|
||||
currentMovementSpeed = movementSpeed;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.useCustomRotationSpeed) {
|
||||
currentRotationSpeed = currentCameraWaypointInfo.rotationSpeed;
|
||||
} else {
|
||||
currentRotationSpeed = rotationSpeed;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.smoothTransitionToNextPoint) {
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
float currentDistance = 0;
|
||||
|
||||
bool checkAngleDifference = false;
|
||||
|
||||
if (currentCameraWaypointInfo.checkRotationIsReached) {
|
||||
checkAngleDifference = true;
|
||||
}
|
||||
|
||||
//while the platform moves from the previous waypoint to the next, then displace it
|
||||
while (!targetReached) {
|
||||
currentCameraTransform.position =
|
||||
Vector3.MoveTowards (currentCameraTransform.position, targetPosition, Time.deltaTime * currentMovementSpeed);
|
||||
|
||||
if (currentCameraWaypointInfo.rotateCameraToNextWaypoint) {
|
||||
targetDirection = targetPosition - currentCameraTransform.position;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.usePointToLook) {
|
||||
if (customTransformToLookActive) {
|
||||
targetDirection = customTransformToLook.position - currentCameraTransform.position;
|
||||
} else {
|
||||
targetDirection = currentCameraWaypointInfo.pointToLook.position - currentCameraTransform.position;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetDirection != Vector3.zero) {
|
||||
targetRotation = Quaternion.LookRotation (targetDirection);
|
||||
|
||||
currentCameraTransform.rotation =
|
||||
Quaternion.Lerp (currentCameraTransform.rotation, targetRotation, Time.deltaTime * currentRotationSpeed);
|
||||
}
|
||||
|
||||
angleDifference = Quaternion.Angle (currentCameraTransform.rotation, targetRotation);
|
||||
|
||||
currentDistance = GKC_Utils.distance (currentCameraTransform.position, targetPosition);
|
||||
|
||||
if (checkAngleDifference) {
|
||||
if (currentDistance < .01f && angleDifference < 1) {
|
||||
targetReached = true;
|
||||
}
|
||||
} else {
|
||||
if (currentDistance < .01f) {
|
||||
targetReached = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
yield return null;
|
||||
}
|
||||
} else {
|
||||
currentCameraTransform.position = targetPosition;
|
||||
|
||||
if (currentCameraWaypointInfo.rotateCameraToNextWaypoint) {
|
||||
targetDirection = targetPosition - currentCameraTransform.position;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.usePointToLook) {
|
||||
if (customTransformToLookActive) {
|
||||
targetDirection = customTransformToLook.position - currentCameraTransform.position;
|
||||
} else {
|
||||
targetDirection = currentCameraWaypointInfo.pointToLook.position - currentCameraTransform.position;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentCameraWaypointInfo.rotateCameraToNextWaypoint && !currentCameraWaypointInfo.usePointToLook) {
|
||||
currentCameraTransform.rotation = currentCameraWaypointInfo.waypointTransform.rotation;
|
||||
} else {
|
||||
if (targetDirection != Vector3.zero) {
|
||||
currentCameraTransform.rotation = Quaternion.LookRotation (targetDirection);
|
||||
}
|
||||
}
|
||||
|
||||
//yield return new WaitForSeconds (currentCameraWaypointInfo.timeOnFixedPosition);
|
||||
|
||||
delay = new WaitForSeconds (currentCameraWaypointInfo.timeOnFixedPosition);
|
||||
|
||||
yield return delay;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.useEventOnPointReached) {
|
||||
currentCameraWaypointInfo.eventOnPointReached.Invoke ();
|
||||
}
|
||||
|
||||
//when the platform reaches the next waypoint
|
||||
currentWaypointIndex++;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
if (useEventOnEnd) {
|
||||
eventOnEnd.Invoke ();
|
||||
}
|
||||
|
||||
if (resetCameraPositionOnEnd) {
|
||||
resetCameraPosition ();
|
||||
}
|
||||
|
||||
waypointInProcess = false;
|
||||
}
|
||||
|
||||
IEnumerator moveAlongBezierCurve ()
|
||||
{
|
||||
waypointInProcess = true;
|
||||
|
||||
if (!snapCameraToFirstSplinePoint) {
|
||||
spline.setInitialSplinePoint (currentCameraTransform.position);
|
||||
}
|
||||
|
||||
float progress = 0;
|
||||
float progressTarget = 1;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
while (!targetReached) {
|
||||
|
||||
if (previousWaypointIndex != currentWaypointIndex) {
|
||||
|
||||
if (previousWaypointIndex != -1) {
|
||||
if (currentCameraWaypointInfo.useEventOnPointReached) {
|
||||
currentCameraWaypointInfo.eventOnPointReached.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
previousWaypointIndex = currentWaypointIndex;
|
||||
|
||||
currentCameraWaypointInfo = waypointList [currentWaypointIndex];
|
||||
|
||||
currentWaypoint = currentCameraWaypointInfo.waypointTransform;
|
||||
|
||||
//wait the amount of time configured
|
||||
if (currentCameraWaypointInfo.useCustomWaitTimeBetweenPoint) {
|
||||
currentWaitTime = currentCameraWaypointInfo.waitTimeBetweenPoints;
|
||||
} else {
|
||||
currentWaitTime = waitTimeBetweenPoints;
|
||||
}
|
||||
|
||||
targetPosition = currentWaypoint.position;
|
||||
targetRotation = currentWaypoint.rotation;
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentWaitTime);
|
||||
|
||||
yield return delay;
|
||||
|
||||
if (currentCameraWaypointInfo.useCustomMovementSpeed) {
|
||||
currentMovementSpeed = currentCameraWaypointInfo.movementSpeed;
|
||||
} else {
|
||||
currentMovementSpeed = movementSpeed;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.useCustomRotationSpeed) {
|
||||
currentRotationSpeed = currentCameraWaypointInfo.rotationSpeed;
|
||||
} else {
|
||||
currentRotationSpeed = rotationSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
currentWaypointIndex = spline.getPointIndex (progress);
|
||||
|
||||
if (useExternalProgress) {
|
||||
if (externalProgress != null) {
|
||||
progress = externalProgress ();
|
||||
} else {
|
||||
Debug.LogError ("useExternalProgress is set but no externalProgress func is assigned");
|
||||
}
|
||||
} else {
|
||||
progress += Time.deltaTime / (bezierDuration * currentMovementSpeed);
|
||||
}
|
||||
|
||||
Vector3 position = spline.GetPoint (progress);
|
||||
currentCameraTransform.position = position;
|
||||
|
||||
if (currentCameraWaypointInfo.rotateCameraToNextWaypoint) {
|
||||
targetDirection = targetPosition - currentCameraTransform.position;
|
||||
}
|
||||
|
||||
if (currentCameraWaypointInfo.usePointToLook) {
|
||||
if (customTransformToLookActive) {
|
||||
targetDirection = customTransformToLook.position - currentCameraTransform.position;
|
||||
} else {
|
||||
targetDirection = currentCameraWaypointInfo.pointToLook.position - currentCameraTransform.position;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetDirection != Vector3.zero) {
|
||||
targetRotation = Quaternion.LookRotation (targetDirection);
|
||||
currentCameraTransform.rotation = Quaternion.Lerp (currentCameraTransform.rotation, targetRotation, Time.deltaTime * currentRotationSpeed);
|
||||
}
|
||||
|
||||
if (progress > progressTarget) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
if (useEventOnEnd) {
|
||||
eventOnEnd.Invoke ();
|
||||
}
|
||||
|
||||
if (resetCameraPositionOnEnd) {
|
||||
resetCameraPosition ();
|
||||
}
|
||||
|
||||
waypointInProcess = false;
|
||||
}
|
||||
|
||||
public void stopWaypointsIfInProcess ()
|
||||
{
|
||||
if (waypointInProcess) {
|
||||
stopMoveThroughWayPointsCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopWaypointsAndResetCameraPosition ()
|
||||
{
|
||||
if (waypointInProcess) {
|
||||
stopMoveThroughWayPointsCoroutine ();
|
||||
|
||||
if (resetCameraPositionOnEnd) {
|
||||
resetCameraPosition ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCameraPosition ()
|
||||
{
|
||||
if (ignoreWaypointOnCurrentViewResult ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resetCameraPositionCoroutine != null) {
|
||||
StopCoroutine (resetCameraPositionCoroutine);
|
||||
}
|
||||
|
||||
resetCameraPositionCoroutine = StartCoroutine (resetCameraCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator resetCameraCoroutine ()
|
||||
{
|
||||
setCameraDirection ();
|
||||
|
||||
if (setThisTransformAsCameraParent) {
|
||||
currentCameraTransform.SetParent (previousCameraParent);
|
||||
}
|
||||
|
||||
Vector3 targetPosition = previousCameraPosition;
|
||||
Quaternion targetRotation = previousCameraRotation;
|
||||
|
||||
Vector3 worldTargetPosition = previousCameraParent.position;
|
||||
float dist = GKC_Utils.distance (currentCameraTransform.position, worldTargetPosition);
|
||||
float duration = dist / resetCameraPositionSpeed;
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
float currentDistance = 0;
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime / duration;
|
||||
|
||||
currentCameraTransform.localPosition = Vector3.Lerp (currentCameraTransform.localPosition, targetPosition, t);
|
||||
currentCameraTransform.localRotation = Quaternion.Lerp (currentCameraTransform.localRotation, targetRotation, t);
|
||||
|
||||
angleDifference = Quaternion.Angle (currentCameraTransform.localRotation, targetRotation);
|
||||
|
||||
currentDistance = GKC_Utils.distance (currentCameraTransform.localPosition, targetPosition);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if (currentDistance < 0.001f && angleDifference < 0.01f) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
if (movementTimer > (duration + 1)) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (pausePlayerCameraEnabled) {
|
||||
currentPlayerCamera.pauseOrPlayCamera (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCameraDirection ()
|
||||
{
|
||||
playerCameraGameObject.transform.rotation = transform.rotation;
|
||||
|
||||
Quaternion newCameraRotation = pivotDirection.localRotation;
|
||||
|
||||
currentPlayerCamera.getPivotCameraTransform ().localRotation = newCameraRotation;
|
||||
|
||||
float newLookAngleValue = newCameraRotation.eulerAngles.x;
|
||||
|
||||
if (newLookAngleValue > 180) {
|
||||
newLookAngleValue -= 360;
|
||||
}
|
||||
|
||||
currentPlayerCamera.setLookAngleValue (new Vector2 (0, newLookAngleValue));
|
||||
}
|
||||
|
||||
public void setCameraWaypointEnabledState (bool state)
|
||||
{
|
||||
cameraWaypointEnabled = state;
|
||||
}
|
||||
|
||||
public void setCustomGameObjectToLook (GameObject newGameObject)
|
||||
{
|
||||
if (newGameObject != null) {
|
||||
setCustomTransformToLook (newGameObject.transform);
|
||||
} else {
|
||||
setCustomTransformToLook (null);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomTransformToLook (Transform newTransform)
|
||||
{
|
||||
customTransformToLook = newTransform;
|
||||
|
||||
customTransformToLookActive = customTransformToLook != null;
|
||||
}
|
||||
|
||||
public void checkEventToStopCutscene ()
|
||||
{
|
||||
if (waypointInProcess) {
|
||||
if (useEventToStopCutScene) {
|
||||
eventToStopCutscene.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
//add a new waypoint
|
||||
public void addNewWayPoint ()
|
||||
{
|
||||
Vector3 newPosition = transform.position;
|
||||
|
||||
if (waypointList.Count > 0) {
|
||||
newPosition = waypointList [waypointList.Count - 1].waypointTransform.position + waypointList [waypointList.Count - 1].waypointTransform.forward;
|
||||
}
|
||||
|
||||
GameObject newWayPoint = new GameObject ();
|
||||
newWayPoint.transform.SetParent (transform);
|
||||
newWayPoint.transform.position = newPosition;
|
||||
newWayPoint.name = (waypointList.Count + 1).ToString ();
|
||||
|
||||
cameraWaypointInfo newCameraWaypointInfo = new cameraWaypointInfo ();
|
||||
newCameraWaypointInfo.Name = newWayPoint.name;
|
||||
newCameraWaypointInfo.waypointTransform = newWayPoint.transform;
|
||||
newCameraWaypointInfo.rotateCameraToNextWaypoint = true;
|
||||
|
||||
waypointList.Add (newCameraWaypointInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewWayPoint (int insertAtIndex)
|
||||
{
|
||||
GameObject newWayPoint = new GameObject ();
|
||||
newWayPoint.transform.SetParent (transform);
|
||||
newWayPoint.name = (waypointList.Count + 1).ToString ();
|
||||
|
||||
cameraWaypointInfo newCameraWaypointInfo = new cameraWaypointInfo ();
|
||||
newCameraWaypointInfo.Name = newWayPoint.name;
|
||||
newCameraWaypointInfo.waypointTransform = newWayPoint.transform;
|
||||
newCameraWaypointInfo.rotateCameraToNextWaypoint = true;
|
||||
|
||||
if (waypointList.Count > 0) {
|
||||
Vector3 lastPosition = waypointList [waypointList.Count - 1].waypointTransform.position + waypointList [waypointList.Count - 1].waypointTransform.forward;
|
||||
newWayPoint.transform.localPosition = lastPosition + waypointList [waypointList.Count - 1].waypointTransform.forward * 2;
|
||||
} else {
|
||||
newWayPoint.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
if (insertAtIndex > -1) {
|
||||
if (waypointList.Count > 0) {
|
||||
newWayPoint.transform.localPosition = waypointList [insertAtIndex].waypointTransform.localPosition + waypointList [insertAtIndex].waypointTransform.forward * 2;
|
||||
}
|
||||
|
||||
waypointList.Insert (insertAtIndex + 1, newCameraWaypointInfo);
|
||||
|
||||
newWayPoint.transform.SetSiblingIndex (insertAtIndex + 1);
|
||||
|
||||
renameAllWaypoints ();
|
||||
} else {
|
||||
waypointList.Add (newCameraWaypointInfo);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void renameAllWaypoints ()
|
||||
{
|
||||
for (int i = 0; i < waypointList.Count; i++) {
|
||||
if (waypointList [i].waypointTransform != null) {
|
||||
waypointList [i].waypointTransform.name = (i + 1).ToString ("000");
|
||||
waypointList [i].Name = (i + 1).ToString ("000");
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void removeWaypoint (int index)
|
||||
{
|
||||
if (waypointList [index].waypointTransform != null) {
|
||||
DestroyImmediate (waypointList [index].waypointTransform.gameObject);
|
||||
}
|
||||
|
||||
waypointList.RemoveAt (index);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void removeAllWaypoints ()
|
||||
{
|
||||
for (int i = 0; i < waypointList.Count; i++) {
|
||||
if (waypointList [i].waypointTransform != null) {
|
||||
DestroyImmediate (waypointList [i].waypointTransform.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
waypointList.Clear ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Camera Waypoin System", gameObject);
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
if (waypointList.Count > 0) {
|
||||
if (waypointList [0].waypointTransform != null) {
|
||||
Gizmos.color = Color.white;
|
||||
Gizmos.DrawLine (waypointList [0].waypointTransform.position, transform.position);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < waypointList.Count; i++) {
|
||||
if (waypointList [i].waypointTransform != null) {
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawSphere (waypointList [i].waypointTransform.position, gizmoRadius);
|
||||
|
||||
if (i + 1 < waypointList.Count) {
|
||||
Gizmos.color = Color.white;
|
||||
Gizmos.DrawLine (waypointList [i].waypointTransform.position, waypointList [i + 1].waypointTransform.position);
|
||||
}
|
||||
|
||||
if (currentWaypoint != null) {
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawSphere (currentWaypoint.position, gizmoRadius);
|
||||
}
|
||||
|
||||
if (waypointList [i].usePointToLook && waypointList [i].pointToLook != null) {
|
||||
Gizmos.color = Color.green;
|
||||
Gizmos.DrawLine (waypointList [i].waypointTransform.position, waypointList [i].pointToLook.position);
|
||||
Gizmos.color = Color.blue;
|
||||
Gizmos.DrawSphere (waypointList [i].pointToLook.position, gizmoRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class cameraWaypointInfo
|
||||
{
|
||||
public string Name;
|
||||
public Transform waypointTransform;
|
||||
|
||||
public bool rotateCameraToNextWaypoint;
|
||||
public bool usePointToLook;
|
||||
public Transform pointToLook;
|
||||
|
||||
public bool smoothTransitionToNextPoint = true;
|
||||
public bool useCustomMovementSpeed;
|
||||
public float movementSpeed;
|
||||
public bool useCustomRotationSpeed;
|
||||
public float rotationSpeed;
|
||||
|
||||
public bool checkRotationIsReached;
|
||||
|
||||
public float timeOnFixedPosition;
|
||||
|
||||
public bool useCustomWaitTimeBetweenPoint;
|
||||
public float waitTimeBetweenPoints;
|
||||
|
||||
public bool useEventOnPointReached;
|
||||
public UnityEvent eventOnPointReached;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b41a39a12e974a4cbed96893647e2f1
|
||||
timeCreated: 1533411804
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Cutscene/cameraWaypointSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,469 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class pauseOrResumePlayerControllerAndCameraSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool searchPlayerOnSceneIfNotAssigned = true;
|
||||
public bool assignPlayerManually;
|
||||
public GameObject currentPlayer;
|
||||
public GameObject playerCameraGameObject;
|
||||
|
||||
public bool unlockCursor;
|
||||
|
||||
public bool enableGamepadCursor;
|
||||
|
||||
public bool resumePlayerAfterDelay;
|
||||
public float delayToResumePlayer;
|
||||
|
||||
public bool activatePlayerMeshModel = true;
|
||||
|
||||
public bool pauseEscapeMenu;
|
||||
|
||||
[Space]
|
||||
[Header ("Time Scale Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCustomTimeScale;
|
||||
public float customTimeScale;
|
||||
|
||||
public bool pauseAIWhenOpenMenu;
|
||||
|
||||
public int pauseCharacterPriority = 1;
|
||||
|
||||
public bool ignoreChangeFixedDeltaTime;
|
||||
|
||||
[Space]
|
||||
[Header ("Camera Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cameraIsMoved;
|
||||
|
||||
public float resetCameraPositionSpeed;
|
||||
public bool setCameraDirectionAtEnd;
|
||||
public Transform cameraDirection;
|
||||
public Transform pivotDirection;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setNewCameraParent;
|
||||
public Transform newCameraParent;
|
||||
|
||||
[Space]
|
||||
[Header ("HUD Settings")]
|
||||
[Space]
|
||||
|
||||
public bool disableSecondaryPlayerHUD;
|
||||
public bool disableAllPlayerHUD = true;
|
||||
public bool disableTouchControls = true;
|
||||
public bool disableDynamiUIElements;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool playerComponentsPaused;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnPause;
|
||||
public UnityEvent eventOnPause;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCamera;
|
||||
public bool useEventOnResume;
|
||||
public UnityEvent eventOnResume;
|
||||
|
||||
playerController playerControllerManager;
|
||||
playerCamera playerCameraManager;
|
||||
headBob headBobManager;
|
||||
playerStatesManager statesManager;
|
||||
menuPause pauseManager;
|
||||
playerComponentsManager mainPlayerComponentsManager;
|
||||
playerInputManager playerInput;
|
||||
|
||||
headTrack mainHeadTrack;
|
||||
|
||||
Transform previousCameraParent;
|
||||
Vector3 previousCameraPosition;
|
||||
Transform mainCamera;
|
||||
|
||||
Coroutine resetCameraPositionCoroutine;
|
||||
|
||||
bool playerIsDriving;
|
||||
|
||||
bool usingDevicePreviously;
|
||||
|
||||
bool headScaleChanged;
|
||||
|
||||
Coroutine resumePlayerCoroutine;
|
||||
|
||||
bool playerAssignedProperly;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (assignPlayerManually) {
|
||||
getCurrentPlayer (currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void getCurrentPlayer (GameObject player)
|
||||
{
|
||||
if (playerComponentsPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayer = player;
|
||||
|
||||
if (currentPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
playerControllerManager = mainPlayerComponentsManager.getPlayerController ();
|
||||
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
playerCameraGameObject = playerCameraManager.gameObject;
|
||||
|
||||
mainCamera = playerCameraManager.getMainCamera ().transform;
|
||||
|
||||
headBobManager = mainPlayerComponentsManager.getHeadBob ();
|
||||
|
||||
statesManager = mainPlayerComponentsManager.getPlayerStatesManager ();
|
||||
|
||||
pauseManager = mainPlayerComponentsManager.getPauseManager ();
|
||||
|
||||
playerInput = mainPlayerComponentsManager.getPlayerInputManager ();
|
||||
|
||||
mainHeadTrack = mainPlayerComponentsManager.getHeadTrack ();
|
||||
|
||||
playerAssignedProperly = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseOrPlayPlayerComponents (bool state)
|
||||
{
|
||||
if (currentPlayer == null || !playerAssignedProperly) {
|
||||
|
||||
findPlayerOnScene ();
|
||||
|
||||
if (currentPlayer == null) {
|
||||
print ("WARNING: no player controller has been assigned to the mission." +
|
||||
" Make sure to use a trigger to activate the mission or assign the player manually");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerComponentsPaused == state) {
|
||||
if (playerComponentsPaused) {
|
||||
print ("Trying to pause the player when it is already paused, avoiding function call to keep the player in same state");
|
||||
} else {
|
||||
print ("Trying to resume the player when it is already resumed, avoiding function call to keep the player in same state");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
playerComponentsPaused = state;
|
||||
|
||||
playerIsDriving = playerControllerManager.isPlayerDriving ();
|
||||
|
||||
playerInput.setAvoidInputActiveState (state);
|
||||
|
||||
if (playerComponentsPaused) {
|
||||
usingDevicePreviously = playerControllerManager.isUsingDevice ();
|
||||
}
|
||||
|
||||
if (!playerIsDriving) {
|
||||
if (!usingDevicePreviously) {
|
||||
playerControllerManager.smoothChangeScriptState (!state);
|
||||
|
||||
mainHeadTrack.setSmoothHeadTrackDisableState (state);
|
||||
|
||||
playerControllerManager.setHeadTrackCanBeUsedState (!state);
|
||||
|
||||
playerControllerManager.setUsingDeviceState (state);
|
||||
|
||||
if (playerComponentsPaused) {
|
||||
headBobManager.stopAllHeadbobMovements ();
|
||||
}
|
||||
|
||||
headBobManager.playOrPauseHeadBob (!state);
|
||||
|
||||
statesManager.checkPlayerStates (false, true, false, true, false, false, true, true);
|
||||
|
||||
playerCameraManager.pauseOrPlayCamera (!state);
|
||||
}
|
||||
}
|
||||
|
||||
if (playerIsDriving) {
|
||||
if (playerComponentsPaused) {
|
||||
headScaleChanged = playerControllerManager.isHeadScaleChanged ();
|
||||
|
||||
if (headScaleChanged) {
|
||||
playerControllerManager.changeHeadScale (false);
|
||||
}
|
||||
} else {
|
||||
if (headScaleChanged) {
|
||||
playerControllerManager.changeHeadScale (true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checkCharacterMesh (state);
|
||||
}
|
||||
|
||||
if (unlockCursor) {
|
||||
pauseManager.showOrHideCursor (playerComponentsPaused);
|
||||
pauseManager.usingDeviceState (playerComponentsPaused);
|
||||
pauseManager.usingSubMenuState (playerComponentsPaused);
|
||||
|
||||
if (enableGamepadCursor) {
|
||||
pauseManager.showOrHideMouseCursorController (playerComponentsPaused);
|
||||
}
|
||||
}
|
||||
|
||||
if (playerIsDriving) {
|
||||
if (disableAllPlayerHUD) {
|
||||
pauseManager.enableOrDisableVehicleHUD (!playerComponentsPaused);
|
||||
}
|
||||
} else {
|
||||
if (!usingDevicePreviously) {
|
||||
if (disableAllPlayerHUD) {
|
||||
pauseManager.enableOrDisablePlayerHUD (!playerComponentsPaused);
|
||||
} else {
|
||||
if (disableSecondaryPlayerHUD) {
|
||||
pauseManager.enableOrDisableSecondaryPlayerHUD (!playerComponentsPaused);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (disableDynamiUIElements) {
|
||||
pauseManager.enableOrDisableDynamicElementsOnScreen (!playerComponentsPaused);
|
||||
}
|
||||
|
||||
if (disableTouchControls) {
|
||||
if (!usingDevicePreviously) {
|
||||
if (pauseManager.isUsingTouchControls ()) {
|
||||
pauseManager.enableOrDisableTouchControlsExternally (!playerComponentsPaused);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!usingDevicePreviously) {
|
||||
pauseManager.enableOrDisableDynamicElementsOnScreen (!playerComponentsPaused);
|
||||
}
|
||||
|
||||
playerInput.setInputPausedForExternalComponentsState (playerComponentsPaused);
|
||||
|
||||
if (playerComponentsPaused) {
|
||||
if (useEventOnPause) {
|
||||
eventToSendCamera.Invoke (mainCamera.gameObject);
|
||||
eventOnPause.Invoke ();
|
||||
}
|
||||
if (cameraIsMoved) {
|
||||
previousCameraParent = mainCamera.parent;
|
||||
previousCameraPosition = mainCamera.localPosition;
|
||||
|
||||
if (setNewCameraParent) {
|
||||
mainCamera.SetParent (newCameraParent);
|
||||
} else {
|
||||
mainCamera.SetParent (null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (useEventOnResume) {
|
||||
eventOnResume.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
stopResumePlayerAfterTimeDelay ();
|
||||
|
||||
if (state) {
|
||||
if (resumePlayerAfterDelay) {
|
||||
resumePlayerAfterTimeDelay ();
|
||||
}
|
||||
}
|
||||
|
||||
if (pauseEscapeMenu) {
|
||||
pauseManager.setPauseGameInputPausedState (state);
|
||||
}
|
||||
|
||||
if (setCustomTimeScale) {
|
||||
if (state) {
|
||||
setTimeScale (customTimeScale);
|
||||
} else {
|
||||
setTimeScale (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (pauseAIWhenOpenMenu) {
|
||||
GKC_Utils.pauseOrResumeAIOnScene (state, pauseCharacterPriority);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTimeScale (float newValue)
|
||||
{
|
||||
Time.timeScale = newValue;
|
||||
|
||||
if (!ignoreChangeFixedDeltaTime) {
|
||||
if (newValue != 0) {
|
||||
Time.fixedDeltaTime = newValue * 0.02f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkCharacterMesh (bool state)
|
||||
{
|
||||
if (activatePlayerMeshModel) {
|
||||
bool firstCameraEnabled = playerCameraManager.isFirstPersonActive ();
|
||||
|
||||
if (firstCameraEnabled) {
|
||||
playerControllerManager.setCharacterMeshGameObjectState (state);
|
||||
}
|
||||
|
||||
if (usingDevicePreviously && !playerControllerManager.isFullBodyAwarenessActive ()) {
|
||||
playerControllerManager.getGravityCenter ().gameObject.SetActive (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCameraPositionIfCharacterPaused ()
|
||||
{
|
||||
if (playerComponentsPaused) {
|
||||
resetCameraPosition ();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCameraPositionIfCharacterPausedWithoutTransition ()
|
||||
{
|
||||
if (!playerComponentsPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cameraIsMoved) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCameraDirection ();
|
||||
|
||||
mainCamera.SetParent (previousCameraParent);
|
||||
|
||||
mainCamera.localPosition = previousCameraPosition;
|
||||
mainCamera.localRotation = Quaternion.identity;
|
||||
|
||||
pauseOrPlayPlayerComponents (false);
|
||||
}
|
||||
|
||||
public void resetCameraPosition ()
|
||||
{
|
||||
if (!cameraIsMoved) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resetCameraPositionCoroutine != null) {
|
||||
StopCoroutine (resetCameraPositionCoroutine);
|
||||
}
|
||||
|
||||
resetCameraPositionCoroutine = StartCoroutine (resetCameraCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator resetCameraCoroutine ()
|
||||
{
|
||||
setCameraDirection ();
|
||||
|
||||
mainCamera.SetParent (previousCameraParent);
|
||||
|
||||
Vector3 targetPosition = previousCameraPosition;
|
||||
Quaternion targeRotation = Quaternion.identity;
|
||||
|
||||
Vector3 worldTargetPosition = previousCameraParent.position;
|
||||
float dist = GKC_Utils.distance (mainCamera.position, worldTargetPosition);
|
||||
float duration = dist / resetCameraPositionSpeed;
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
float currentDistance = 0;
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime / duration;
|
||||
|
||||
mainCamera.localPosition = Vector3.Lerp (mainCamera.localPosition, targetPosition, t);
|
||||
mainCamera.localRotation = Quaternion.Lerp (mainCamera.localRotation, targeRotation, t);
|
||||
|
||||
angleDifference = Quaternion.Angle (mainCamera.localRotation, targeRotation);
|
||||
|
||||
currentDistance = GKC_Utils.distance (mainCamera.localPosition, targetPosition);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if ((currentDistance < 0.001f && angleDifference < 0.1f) || movementTimer > (duration + 1)) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
pauseOrPlayPlayerComponents (false);
|
||||
}
|
||||
|
||||
public void setCameraDirection ()
|
||||
{
|
||||
if (setCameraDirectionAtEnd) {
|
||||
playerCameraGameObject.transform.rotation = cameraDirection.rotation;
|
||||
|
||||
Quaternion newCameraRotation = pivotDirection.localRotation;
|
||||
|
||||
playerCameraManager.getPivotCameraTransform ().localRotation = newCameraRotation;
|
||||
|
||||
float newLookAngleValue = newCameraRotation.eulerAngles.x;
|
||||
|
||||
if (newLookAngleValue > 180) {
|
||||
newLookAngleValue -= 360;
|
||||
}
|
||||
|
||||
playerCameraManager.setLookAngleValue (new Vector2 (0, newLookAngleValue));
|
||||
}
|
||||
}
|
||||
|
||||
public void resumePlayerAfterTimeDelay ()
|
||||
{
|
||||
stopResumePlayerAfterTimeDelay ();
|
||||
|
||||
resumePlayerCoroutine = StartCoroutine (resumePlayerAfterTimeDelayCoroutine ());
|
||||
}
|
||||
|
||||
public void stopResumePlayerAfterTimeDelay ()
|
||||
{
|
||||
if (resumePlayerCoroutine != null) {
|
||||
StopCoroutine (resumePlayerCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator resumePlayerAfterTimeDelayCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (delayToResumePlayer);
|
||||
|
||||
pauseOrPlayPlayerComponents (false);
|
||||
}
|
||||
|
||||
public void findPlayerOnScene ()
|
||||
{
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
getCurrentPlayer (GKC_Utils.findMainPlayerOnScene ());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e963d1ecb2c6aa479602abcd95ec639
|
||||
timeCreated: 1533410237
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Cutscene/pauseOrResumePlayerControllerAndCameraSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class simpleShowHideMouseCursor : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showOrHideMouseCursorEnabled = true;
|
||||
public bool enableGamepadCursor;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool searchMainPlayerOnSceneEnabled;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showMouseCursorActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public menuPause pauseManager;
|
||||
|
||||
|
||||
public void showMouseCursor ()
|
||||
{
|
||||
showOrHideMouseCursor (true);
|
||||
}
|
||||
|
||||
public void hideMouseCursor ()
|
||||
{
|
||||
showOrHideMouseCursor (false);
|
||||
}
|
||||
|
||||
public void showOrHideMouseCursor (bool state)
|
||||
{
|
||||
if (showOrHideMouseCursorEnabled) {
|
||||
if (showMouseCursorActive == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pauseManager == null) {
|
||||
if (searchMainPlayerOnSceneEnabled) {
|
||||
pauseManager = GKC_Utils.findMainPlayergetPauseManagerOnScene ();
|
||||
|
||||
if (pauseManager == null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
showMouseCursorActive = state;
|
||||
|
||||
pauseManager.showOrHideCursor (showMouseCursorActive);
|
||||
pauseManager.usingDeviceState (showMouseCursorActive);
|
||||
pauseManager.usingSubMenuState (showMouseCursorActive);
|
||||
|
||||
if (enableGamepadCursor) {
|
||||
pauseManager.showOrHideMouseCursorController (showMouseCursorActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 071ad3aa3c1a4744db2c63a5817b2e67
|
||||
timeCreated: 1692077191
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Cutscene/simpleShowHideMouseCursor.cs
|
||||
uploadId: 814740
|
||||
9
Assets/Game Kit Controller/Scripts/Camera/Others.meta
Normal file
9
Assets/Game Kit Controller/Scripts/Camera/Others.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45d12c6b5a1dbdb4a9b68f314dd61f99
|
||||
folderAsset: yes
|
||||
timeCreated: 1576722120
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,374 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dynamicSplitScreenSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool dynamicSplitScreenActive = true;
|
||||
|
||||
//The distance at which the splitscreen will be activated.
|
||||
public float splitDistance = 5;
|
||||
|
||||
//The color and width of the splitter which splits the two screens up.
|
||||
public Color splitterColor;
|
||||
public float splitterWidth;
|
||||
|
||||
public LayerMask secondPlayerCameraCullingMask;
|
||||
public LayerMask regularCameraCullingMask;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public Vector3 extraPositionOffset1TopDown;
|
||||
public Vector3 extraPositionOffset2TopDown;
|
||||
//
|
||||
// public Vector3 extraPositionOffset12_5dX;
|
||||
// public Vector3 extraPositionOffset22_5dX;
|
||||
//
|
||||
// public Vector3 extraPositionOffset12_5dZ;
|
||||
// public Vector3 extraPositionOffset22_5dZ;
|
||||
public bool usingTopDownView;
|
||||
|
||||
public float screenRotationSpeed = 20;
|
||||
|
||||
[Space]
|
||||
[Header ("2.5D Settings")]
|
||||
[Space]
|
||||
|
||||
public bool using2_5dView;
|
||||
public bool movingOnXAxis;
|
||||
|
||||
public float minHorizontalAxisDistanceToOffset2_5d;
|
||||
public float horizontaAxisOffset2_5d;
|
||||
|
||||
public float maxHorizontalDistanceForVerticalSplit = 20;
|
||||
|
||||
public bool reverseMovementDirection;
|
||||
|
||||
public Vector2 farScreenRotationClampValues;
|
||||
public Vector2 closeScreenRotationClampValues;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool maxDistanceReached;
|
||||
public bool player1OnLowerPosition;
|
||||
|
||||
public float currentScreenRotation;
|
||||
|
||||
public bool player1OnLeftSide;
|
||||
public float currentHorizontalDistance;
|
||||
|
||||
public float currentDistance;
|
||||
|
||||
public Vector3 currentExtraPositionOffset1;
|
||||
public Vector3 currentExtraPositionOffset2;
|
||||
|
||||
public bool closeVerticalPosition;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform player1;
|
||||
public Transform player2;
|
||||
|
||||
//The two cameras, both of which are initalized/referenced in the start function.
|
||||
public playerCamera mainPlayerCameraManager1;
|
||||
public playerCamera mainPlayerCameraManager2;
|
||||
|
||||
public Camera camera1;
|
||||
public Camera camera2;
|
||||
|
||||
//The two quads used to draw the second screen, both of which are initalized in the start function.
|
||||
public GameObject split;
|
||||
public GameObject splitter;
|
||||
|
||||
bool positionCompare;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (!dynamicSplitScreenActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
splitter.GetComponent<Renderer> ().sortingOrder = 2;
|
||||
|
||||
if (camera1 != null) {
|
||||
camera1.depth = 1;
|
||||
} else {
|
||||
dynamicSplitScreenActive = false;
|
||||
}
|
||||
|
||||
if (camera2 != null) {
|
||||
camera2.depth = 0;
|
||||
} else {
|
||||
dynamicSplitScreenActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (!dynamicSplitScreenActive) {
|
||||
if (maxDistanceReached) {
|
||||
mainPlayerCameraManager1.setFollowingMultipleTargetsState (true, false);
|
||||
mainPlayerCameraManager2.setFollowingMultipleTargetsState (true, false);
|
||||
|
||||
mainPlayerCameraManager1.setextraPositionOffsetValue (Vector3.zero);
|
||||
mainPlayerCameraManager2.setextraPositionOffsetValue (Vector3.zero);
|
||||
|
||||
maxDistanceReached = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Gets the z axis distance between the two players and just the standard distance.
|
||||
|
||||
currentDistance = GKC_Utils.distance (player1.position, player2.position);
|
||||
|
||||
//Sets the angle of the player up, depending on who's leading on the x axis.
|
||||
currentScreenRotation = 0;
|
||||
|
||||
if (usingTopDownView) {
|
||||
float zDistance = player1.position.z - player2.position.z;
|
||||
|
||||
if (player1.position.x <= player2.position.x) {
|
||||
currentScreenRotation = Mathf.Rad2Deg * Mathf.Acos (zDistance / currentDistance);
|
||||
} else {
|
||||
currentScreenRotation = Mathf.Rad2Deg * Mathf.Asin (zDistance / currentDistance) - 90;
|
||||
}
|
||||
}
|
||||
|
||||
player1OnLeftSide = false;
|
||||
|
||||
if (using2_5dView) {
|
||||
|
||||
closeVerticalPosition = (player1.position - player2.position).y < 0.5f;
|
||||
|
||||
player1OnLowerPosition = player1.position.y <= player2.position.y;
|
||||
|
||||
if (movingOnXAxis) {
|
||||
if (reverseMovementDirection) {
|
||||
positionCompare = player1.position.x >= player2.position.x;
|
||||
} else {
|
||||
positionCompare = player1.position.x <= player2.position.x;
|
||||
}
|
||||
} else {
|
||||
if (reverseMovementDirection) {
|
||||
positionCompare = player1.position.z >= player2.position.z;
|
||||
} else {
|
||||
positionCompare = player1.position.z <= player2.position.z;
|
||||
}
|
||||
}
|
||||
|
||||
if (movingOnXAxis) {
|
||||
if (positionCompare) {
|
||||
player1OnLeftSide = true;
|
||||
}
|
||||
} else {
|
||||
if (positionCompare) {
|
||||
player1OnLeftSide = true;
|
||||
}
|
||||
}
|
||||
|
||||
currentHorizontalDistance = 0;
|
||||
if (movingOnXAxis) {
|
||||
currentHorizontalDistance = player1.position.x - player2.position.x;
|
||||
} else {
|
||||
currentHorizontalDistance = player1.position.z - player2.position.z;
|
||||
}
|
||||
|
||||
if (player1OnLeftSide) {
|
||||
currentScreenRotation = Mathf.Rad2Deg * Mathf.Asin (currentHorizontalDistance / currentDistance);
|
||||
} else {
|
||||
currentScreenRotation = Mathf.Rad2Deg * Mathf.Acos (currentHorizontalDistance / currentDistance) + 90;
|
||||
}
|
||||
|
||||
if (player1OnLeftSide) {
|
||||
if (currentDistance > maxHorizontalDistanceForVerticalSplit) {
|
||||
currentScreenRotation = Mathf.Clamp (currentScreenRotation, farScreenRotationClampValues.x, farScreenRotationClampValues.y);
|
||||
} else {
|
||||
currentScreenRotation = Mathf.Clamp (currentScreenRotation, closeScreenRotationClampValues.x, closeScreenRotationClampValues.y);
|
||||
}
|
||||
} else {
|
||||
if (currentDistance > maxHorizontalDistanceForVerticalSplit) {
|
||||
currentScreenRotation = Mathf.Clamp (currentScreenRotation, 180 + farScreenRotationClampValues.x, 180 + farScreenRotationClampValues.y);
|
||||
} else {
|
||||
currentScreenRotation = Mathf.Clamp (currentScreenRotation, 180 + closeScreenRotationClampValues.x, 180 + closeScreenRotationClampValues.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Rotates the splitter according to the new angle.
|
||||
Quaternion targetRotation = Quaternion.Euler (new Vector3 (0, 0, currentScreenRotation));
|
||||
|
||||
splitter.transform.localRotation = Quaternion.Lerp (splitter.transform.localRotation, targetRotation, Time.deltaTime * screenRotationSpeed);
|
||||
|
||||
//Gets the exact midpoint between the two players.
|
||||
Vector3 midPoint = new Vector3 ((player1.position.x + player2.position.x) / 2, (player1.position.y + player2.position.y) / 2, (player1.position.z + player2.position.z) / 2);
|
||||
|
||||
//Waits for the two cameras to split and then calcuates a midpoint relevant to the difference in position between the two cameras.
|
||||
if (currentDistance > splitDistance) {
|
||||
Vector3 offset = midPoint - player1.position;
|
||||
offset.x = Mathf.Clamp (offset.x, -splitDistance / 2, splitDistance / 2);
|
||||
offset.y = Mathf.Clamp (offset.y, -splitDistance / 2, splitDistance / 2);
|
||||
offset.z = Mathf.Clamp (offset.z, -splitDistance / 2, splitDistance / 2);
|
||||
midPoint = player1.position + offset;
|
||||
|
||||
Vector3 offset2 = midPoint - player2.position;
|
||||
offset2.x = Mathf.Clamp (offset.x, -splitDistance / 2, splitDistance / 2);
|
||||
offset2.y = Mathf.Clamp (offset.y, -splitDistance / 2, splitDistance / 2);
|
||||
offset2.z = Mathf.Clamp (offset.z, -splitDistance / 2, splitDistance / 2);
|
||||
Vector3 midPoint2 = player2.position - offset;
|
||||
|
||||
//Sets the splitter and camera to active and sets the second camera position as to avoid lerping continuity errors.
|
||||
if (splitter.activeSelf == false) {
|
||||
splitter.SetActive (true);
|
||||
camera2.enabled = true;
|
||||
}
|
||||
|
||||
if (!maxDistanceReached) {
|
||||
mainPlayerCameraManager1.setFollowingMultipleTargetsState (false, false);
|
||||
mainPlayerCameraManager2.setFollowingMultipleTargetsState (false, false);
|
||||
|
||||
maxDistanceReached = true;
|
||||
}
|
||||
|
||||
if (usingTopDownView) {
|
||||
currentExtraPositionOffset1 = extraPositionOffset1TopDown;
|
||||
currentExtraPositionOffset2 = extraPositionOffset2TopDown;
|
||||
}
|
||||
|
||||
if (using2_5dView) {
|
||||
if (movingOnXAxis) {
|
||||
|
||||
currentExtraPositionOffset1.y = Mathf.Lerp (horizontaAxisOffset2_5d, 0, currentHorizontalDistance / minHorizontalAxisDistanceToOffset2_5d);
|
||||
currentExtraPositionOffset2.y = Mathf.Lerp (horizontaAxisOffset2_5d, 0, currentHorizontalDistance / minHorizontalAxisDistanceToOffset2_5d);
|
||||
|
||||
if (closeVerticalPosition) {
|
||||
currentExtraPositionOffset1.y = Mathf.Lerp (currentExtraPositionOffset1.y, 0, Time.deltaTime * 3);
|
||||
currentExtraPositionOffset2.y = Mathf.Lerp (currentExtraPositionOffset2.y, 0, Time.deltaTime * 3);
|
||||
} else {
|
||||
if (player1OnLeftSide) {
|
||||
if (player1OnLowerPosition) {
|
||||
currentExtraPositionOffset2.y = -currentExtraPositionOffset2.y;
|
||||
} else {
|
||||
currentExtraPositionOffset1.y = -currentExtraPositionOffset1.y;
|
||||
}
|
||||
} else {
|
||||
if (player1OnLowerPosition) {
|
||||
currentExtraPositionOffset1.y = -currentExtraPositionOffset1.y;
|
||||
} else {
|
||||
currentExtraPositionOffset2.y = -currentExtraPositionOffset2.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }else{
|
||||
// currentExtraPositionOffset1 = Mathf.Lerp (currentExtraPositionOffset1, multipleTargetsMaxFov, currentMultipleTargetsFov / multipleTargetsFovSpeed);
|
||||
// currentExtraPositionOffset2 = Mathf.Lerp (multipleTargetsMinFov, multipleTargetsMaxFov, currentMultipleTargetsFov / multipleTargetsFovSpeed);
|
||||
// }
|
||||
// if (playerOnLowerPosition) {
|
||||
// currentExtraPositionOffset1 = extraPositionOffset12_5dX;
|
||||
// currentExtraPositionOffset2 = -extraPositionOffset22_5dX;
|
||||
// } else {
|
||||
// currentExtraPositionOffset1 = -extraPositionOffset12_5dX;
|
||||
// currentExtraPositionOffset2 = extraPositionOffset22_5dX;
|
||||
// }
|
||||
} else {
|
||||
// if (playerOnLowerPosition) {
|
||||
// currentExtraPositionOffset1 = -extraPositionOffset12_5dZ;
|
||||
// currentExtraPositionOffset2 = extraPositionOffset22_5dZ;
|
||||
// } else {
|
||||
// currentExtraPositionOffset1 = extraPositionOffset12_5dZ;
|
||||
// currentExtraPositionOffset2 = -extraPositionOffset22_5dZ;
|
||||
// }
|
||||
}
|
||||
|
||||
midPoint.y = player1.position.y;
|
||||
midPoint2.y = player2.position.y;
|
||||
}
|
||||
|
||||
mainPlayerCameraManager1.setextraPositionOffsetValue (currentExtraPositionOffset1 + midPoint - mainPlayerCameraManager1.transform.position);
|
||||
mainPlayerCameraManager2.setextraPositionOffsetValue (currentExtraPositionOffset2 + midPoint2 - mainPlayerCameraManager2.transform.position);
|
||||
|
||||
} else {
|
||||
//Deactivates the splitter and camera once the distance is less than the splitting distance (assuming it was at one point).
|
||||
if (splitter.activeSelf) {
|
||||
|
||||
splitter.SetActive (false);
|
||||
camera2.enabled = false;
|
||||
}
|
||||
|
||||
if (maxDistanceReached) {
|
||||
mainPlayerCameraManager1.setFollowingMultipleTargetsState (true, false);
|
||||
mainPlayerCameraManager2.setFollowingMultipleTargetsState (true, false);
|
||||
|
||||
mainPlayerCameraManager1.setextraPositionOffsetValue (Vector3.zero);
|
||||
mainPlayerCameraManager2.setextraPositionOffsetValue (Vector3.zero);
|
||||
|
||||
maxDistanceReached = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDynamicSplitScreenActiveState (bool state, GameObject newPlayer1, GameObject newPlayer2, bool creatingCharactersOnEditor)
|
||||
{
|
||||
dynamicSplitScreenActive = state;
|
||||
|
||||
enabled = state;
|
||||
|
||||
if (newPlayer1 != null) {
|
||||
player1 = newPlayer1.transform;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager1 = player1.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager1 != null) {
|
||||
mainPlayerCameraManager1 = mainPlayerComponentsManager1.getPlayerCamera ();
|
||||
|
||||
camera1 = mainPlayerCameraManager1.getMainCamera ();
|
||||
}
|
||||
}
|
||||
|
||||
if (newPlayer2 != null) {
|
||||
player2 = newPlayer2.transform;
|
||||
playerComponentsManager mainPlayerComponentsManager2 = player2.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager2 != null) {
|
||||
mainPlayerCameraManager2 = mainPlayerComponentsManager2.getPlayerCamera ();
|
||||
|
||||
camera2 = mainPlayerCameraManager2.getMainCamera ();
|
||||
|
||||
if (state) {
|
||||
camera2.cullingMask = secondPlayerCameraCullingMask;
|
||||
} else {
|
||||
camera2.cullingMask = regularCameraCullingMask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print ("Setting dynamic split camera state as " + state);
|
||||
|
||||
if (creatingCharactersOnEditor) {
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDynamicSplitScreenActiveState (bool state)
|
||||
{
|
||||
dynamicSplitScreenActive = state;
|
||||
|
||||
enabled = state;
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d6eb807371edd8489e16de2e70df1fb
|
||||
timeCreated: 1575070643
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Others/dynamicSplitScreenSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,268 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class playerCullingSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cullingSystemEnabled = true;
|
||||
|
||||
public float minDistanceToApplyShader = 1;
|
||||
public float minCullingShaderValue = 0.2f;
|
||||
public float slerpCullingSpeed = 1;
|
||||
|
||||
public float stippleSize;
|
||||
|
||||
public string transparentAmountName = "_TransparentAmount";
|
||||
|
||||
public bool setStippleSize;
|
||||
public string stippleSizeName = "_StippleSize";
|
||||
|
||||
[Space]
|
||||
[Header ("Player GameObject List")]
|
||||
[Space]
|
||||
|
||||
public List<GameObject> playerGameObjectList = new List<GameObject> ();
|
||||
public List<GameObject> playerGameObjectWithChildList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool pauseCullingState;
|
||||
public float cullingAmountToApply;
|
||||
public bool cullingActive;
|
||||
public float currentDistance;
|
||||
public float currentCullingValue;
|
||||
public bool materialsChangedChecked;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Shader cullingShader;
|
||||
public Transform playerTransform;
|
||||
public Transform cameraTransform;
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
public List<Renderer> rendererParts = new List<Renderer> ();
|
||||
public List<Shader> originalShader = new List<Shader> ();
|
||||
public List<Material> materialList = new List<Material> ();
|
||||
|
||||
float previousCullingValue;
|
||||
|
||||
bool materialsStored;
|
||||
|
||||
int transparentAmountID;
|
||||
|
||||
int stippleSizeID;
|
||||
|
||||
float previousStippleSize = -1;
|
||||
|
||||
int materialsCount;
|
||||
|
||||
Material temporalMaterial;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (rendererParts.Count == 0) {
|
||||
storePlayerRenderer ();
|
||||
}
|
||||
|
||||
transparentAmountID = Shader.PropertyToID (transparentAmountName);
|
||||
|
||||
stippleSizeID = Shader.PropertyToID (stippleSizeName);
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (!cullingSystemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentDistance = GKC_Utils.distance (playerTransform.position, cameraTransform.position);
|
||||
|
||||
if (!pauseCullingState && currentDistance < minDistanceToApplyShader) {
|
||||
cullingAmountToApply = currentDistance / minDistanceToApplyShader;
|
||||
|
||||
cullingActive = true;
|
||||
} else {
|
||||
cullingActive = false;
|
||||
|
||||
cullingAmountToApply = 1;
|
||||
}
|
||||
|
||||
if (cullingActive) {
|
||||
if (mainPlayerCamera.isFirstPersonActive ()) {
|
||||
cullingActive = false;
|
||||
} else {
|
||||
if (mainPlayerCamera.isFullBodyAwarenessActive ()) {
|
||||
cullingActive = false;
|
||||
} else {
|
||||
bool isCameraTypeFree = mainPlayerCamera.isCameraTypeFree ();
|
||||
|
||||
if (!isCameraTypeFree) {
|
||||
cullingActive = false;
|
||||
} else {
|
||||
if (mainPlayerCamera.isPlayerAiming ()) {
|
||||
cullingAmountToApply = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (materialsChangedChecked != cullingActive) {
|
||||
materialsChangedChecked = cullingActive;
|
||||
|
||||
if (!materialsStored) {
|
||||
getMaterialList ();
|
||||
|
||||
materialsStored = true;
|
||||
}
|
||||
|
||||
materialsCount = materialList.Count;
|
||||
|
||||
for (int j = 0; j < materialsCount; j++) {
|
||||
temporalMaterial = materialList [j];
|
||||
|
||||
if (cullingActive) {
|
||||
temporalMaterial.shader = cullingShader;
|
||||
|
||||
if (setStippleSize) {
|
||||
if (stippleSize != previousStippleSize) {
|
||||
previousStippleSize = stippleSize;
|
||||
|
||||
temporalMaterial.SetFloat (stippleSizeID, stippleSize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
temporalMaterial.shader = originalShader [j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentCullingValue = Mathf.Lerp (currentCullingValue, cullingAmountToApply, Time.deltaTime * slerpCullingSpeed);
|
||||
|
||||
if (currentCullingValue <= 1) {
|
||||
if (Mathf.Abs (currentCullingValue - previousCullingValue) > 0.01f) {
|
||||
|
||||
materialsCount = materialList.Count;
|
||||
|
||||
for (int j = 0; j < materialsCount; j++) {
|
||||
materialList [j].SetFloat (transparentAmountID, currentCullingValue);
|
||||
}
|
||||
|
||||
previousCullingValue = currentCullingValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPauseCullingState (bool state)
|
||||
{
|
||||
pauseCullingState = state;
|
||||
}
|
||||
|
||||
public void getMaterialList ()
|
||||
{
|
||||
if (materialList.Count == 0) {
|
||||
int rendererPartsCount = rendererParts.Count;
|
||||
|
||||
for (int i = 0; i < rendererPartsCount; i++) {
|
||||
Renderer currentRenderer = rendererParts [i];
|
||||
|
||||
if (currentRenderer != null) {
|
||||
|
||||
if (currentRenderer.material.shader != null) {
|
||||
int materialsLength = currentRenderer.materials.Length;
|
||||
|
||||
for (int j = 0; j < materialsLength; j++) {
|
||||
|
||||
Material currentMaterial = currentRenderer.materials [j];
|
||||
|
||||
if (currentMaterial != null) {
|
||||
|
||||
materialList.Add (currentMaterial);
|
||||
|
||||
originalShader.Add (currentMaterial.shader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRendererList ()
|
||||
{
|
||||
rendererParts.Clear ();
|
||||
|
||||
originalShader.Clear ();
|
||||
}
|
||||
|
||||
public void storePlayerRenderer ()
|
||||
{
|
||||
clearRendererList ();
|
||||
|
||||
for (int i = 0; i < playerGameObjectList.Count; i++) {
|
||||
GameObject currentObject = playerGameObjectList [i];
|
||||
|
||||
if (currentObject != null) {
|
||||
Renderer currentRenderer = currentObject.GetComponent<Renderer> ();
|
||||
|
||||
rendererParts.Add (currentRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < playerGameObjectWithChildList.Count; i++) {
|
||||
GameObject currentObject = playerGameObjectWithChildList [i];
|
||||
|
||||
if (currentObject != null) {
|
||||
Component[] components = currentObject.GetComponentsInChildren (typeof(Renderer));
|
||||
|
||||
int componentsLength = components.Length;
|
||||
|
||||
for (int j = 0; j < componentsLength; j++) {
|
||||
rendererParts.Add (components [j] as Renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print ("Total amount of " + rendererParts.Count + " render found");
|
||||
}
|
||||
|
||||
public void storePlayerRendererFromEditor ()
|
||||
{
|
||||
storePlayerRenderer ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void clearRendererListFromEditor ()
|
||||
{
|
||||
clearRendererList ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCullingSystemEnabledState (bool state)
|
||||
{
|
||||
cullingSystemEnabled = state;
|
||||
}
|
||||
|
||||
public void setCullingSystemEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setCullingSystemEnabledState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Player Culling System", gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deebc3595353be54bbbde2b69855bab7
|
||||
timeCreated: 1582305065
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Others/playerCullingSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,332 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class setTransparentSurfaces : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkSurfaceEnabled = true;
|
||||
|
||||
public bool checkSurfaceActiveAtStart;
|
||||
|
||||
public bool checkSurfaceActive;
|
||||
|
||||
public bool lockedCameraActive;
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
public float capsuleCastRadius = 0.3f;
|
||||
|
||||
public bool useCustomShader;
|
||||
public Shader customShader;
|
||||
|
||||
public string mainManagerName = "Set Transparent Surfaces Manager";
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool surfaceFound;
|
||||
public bool surfaceFoundPreviously;
|
||||
public bool playerIsUsingDevices;
|
||||
public bool playerIsUsingDevicesPreviously;
|
||||
|
||||
public List<GameObject> currentSurfaceGameObjectFoundList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnStartCheckSurface;
|
||||
public UnityEvent eventOnStartCheckSurface;
|
||||
public bool useEventsOnStopCheckSurface;
|
||||
public UnityEvent eventOnStopCheckSurface;
|
||||
|
||||
public bool useEventOnSurfaceFound;
|
||||
public UnityEvent eventOnSurfaceFound;
|
||||
public bool useEventOnNoSurfaceFound;
|
||||
public UnityEvent eventOnNoSurfaceFound;
|
||||
|
||||
[Space]
|
||||
[Header ("Gizmo Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showGizmo;
|
||||
public Color sphereColor = Color.green;
|
||||
public Color cubeColor = Color.blue;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerController playerControllerManager;
|
||||
public int playerID;
|
||||
public Transform rayOriginPositionFreeCamera;
|
||||
public Transform rayTargetPositionFreeCamera;
|
||||
public Transform rayOriginPositionLockedCamera;
|
||||
public Transform rayTargetPositionLockedCamera;
|
||||
|
||||
public setTransparentSurfacesSystem setTransparentSurfacesManager;
|
||||
|
||||
RaycastHit[] hits;
|
||||
float distanceToTarget;
|
||||
|
||||
Vector3 rayDirection;
|
||||
List<GameObject> surfaceGameObjectList = new List<GameObject> ();
|
||||
Vector3 point1;
|
||||
Vector3 point2;
|
||||
|
||||
GameObject currentSurfaceGameObjectFound;
|
||||
|
||||
setTransparentSurfacesSystem.surfaceInfo currentSurfaceInfo;
|
||||
|
||||
Transform currentRayOriginPosition;
|
||||
Transform currentRayTargetPosition;
|
||||
|
||||
bool playerLocated;
|
||||
|
||||
bool setTransparentSurfacesManagerLocated;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
setTransparentSurfacesManagerLocated = setTransparentSurfacesManager != null;
|
||||
|
||||
if (!setTransparentSurfacesManagerLocated) {
|
||||
setTransparentSurfacesManager = setTransparentSurfacesSystem.Instance;
|
||||
|
||||
setTransparentSurfacesManagerLocated = setTransparentSurfacesManager != null;
|
||||
}
|
||||
|
||||
if (!setTransparentSurfacesManagerLocated) {
|
||||
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (setTransparentSurfacesSystem.getMainManagerName (), typeof(setTransparentSurfacesSystem), true);
|
||||
|
||||
setTransparentSurfacesManager = setTransparentSurfacesSystem.Instance;
|
||||
|
||||
setTransparentSurfacesManagerLocated = setTransparentSurfacesManager != null;
|
||||
}
|
||||
|
||||
if (!setTransparentSurfacesManagerLocated) {
|
||||
setTransparentSurfacesManager = FindObjectOfType<setTransparentSurfacesSystem> ();
|
||||
|
||||
setTransparentSurfacesManagerLocated = setTransparentSurfacesManager != null;
|
||||
}
|
||||
|
||||
if (!setTransparentSurfacesManagerLocated) {
|
||||
checkSurfaceEnabled = false;
|
||||
|
||||
checkSurfaceActive = false;
|
||||
}
|
||||
|
||||
if (playerControllerManager != null) {
|
||||
playerID = playerControllerManager.getPlayerID ();
|
||||
|
||||
playerLocated = true;
|
||||
}
|
||||
|
||||
if (checkSurfaceActiveAtStart) {
|
||||
setCheckSurfaceActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (checkSurfaceActive) {
|
||||
if (lockedCameraActive) {
|
||||
currentRayOriginPosition = rayOriginPositionLockedCamera;
|
||||
currentRayTargetPosition = rayTargetPositionLockedCamera;
|
||||
} else {
|
||||
currentRayOriginPosition = rayOriginPositionFreeCamera;
|
||||
currentRayTargetPosition = rayTargetPositionFreeCamera;
|
||||
}
|
||||
|
||||
distanceToTarget = GKC_Utils.distance (currentRayOriginPosition.position, currentRayTargetPosition.position);
|
||||
rayDirection = currentRayOriginPosition.position - currentRayTargetPosition.position;
|
||||
rayDirection = rayDirection / rayDirection.magnitude;
|
||||
|
||||
if (showGizmo) {
|
||||
Debug.DrawLine (currentRayTargetPosition.position, (distanceToTarget * rayDirection) + currentRayTargetPosition.position, Color.red, 2);
|
||||
}
|
||||
|
||||
point1 = currentRayOriginPosition.position - capsuleCastRadius * rayDirection;
|
||||
point2 = currentRayTargetPosition.position + capsuleCastRadius * rayDirection;
|
||||
|
||||
hits = Physics.CapsuleCastAll (point1, point2, capsuleCastRadius, rayDirection, 0, layer);
|
||||
|
||||
surfaceFound = hits.Length > 0;
|
||||
|
||||
if (surfaceFound != surfaceFoundPreviously) {
|
||||
surfaceFoundPreviously = surfaceFound;
|
||||
|
||||
if (surfaceFoundPreviously) {
|
||||
if (useEventOnSurfaceFound) {
|
||||
eventOnSurfaceFound.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (useEventOnNoSurfaceFound) {
|
||||
eventOnNoSurfaceFound.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (playerLocated) {
|
||||
playerIsUsingDevices = playerControllerManager.isUsingDevice ();
|
||||
}
|
||||
|
||||
if (playerIsUsingDevices != playerIsUsingDevicesPreviously) {
|
||||
playerIsUsingDevicesPreviously = playerIsUsingDevices;
|
||||
|
||||
changeSurfacesToTransparentOrRegularTemporaly (!playerIsUsingDevices);
|
||||
}
|
||||
|
||||
surfaceGameObjectList.Clear ();
|
||||
|
||||
for (int i = 0; i < hits.Length; i++) {
|
||||
currentSurfaceGameObjectFound = hits [i].collider.gameObject;
|
||||
|
||||
if (!setTransparentSurfacesManager.listContainsSurface (currentSurfaceGameObjectFound)) {
|
||||
if (useCustomShader) {
|
||||
setTransparentSurfacesManager.addNewSurface (currentSurfaceGameObjectFound, customShader);
|
||||
} else {
|
||||
setTransparentSurfacesManager.addNewSurface (currentSurfaceGameObjectFound, null);
|
||||
}
|
||||
} else {
|
||||
setTransparentSurfacesManager.checkSurfaceToSetTransparentAgain (currentSurfaceGameObjectFound);
|
||||
}
|
||||
|
||||
if (!currentSurfaceGameObjectFoundList.Contains (currentSurfaceGameObjectFound)) {
|
||||
currentSurfaceGameObjectFoundList.Add (currentSurfaceGameObjectFound);
|
||||
setTransparentSurfacesManager.addPlayerIDToSurface (playerID, currentSurfaceGameObjectFound);
|
||||
}
|
||||
|
||||
surfaceGameObjectList.Add (currentSurfaceGameObjectFound);
|
||||
}
|
||||
|
||||
for (int i = 0; i < setTransparentSurfacesManager.surfaceInfoList.Count; i++) {
|
||||
currentSurfaceInfo = setTransparentSurfacesManager.surfaceInfoList [i];
|
||||
|
||||
if (!surfaceGameObjectList.Contains (currentSurfaceInfo.surfaceGameObject)) {
|
||||
if (currentSurfaceInfo.playerIDs.Contains (playerID)) {
|
||||
|
||||
setTransparentSurfacesManager.removePlayerIDToSurface (playerID, i);
|
||||
}
|
||||
|
||||
if (currentSurfaceGameObjectFoundList.Contains (currentSurfaceInfo.surfaceGameObject)) {
|
||||
currentSurfaceGameObjectFoundList.Remove (currentSurfaceInfo.surfaceGameObject);
|
||||
}
|
||||
|
||||
if (currentSurfaceInfo.numberOfPlayersFound < 1 && !currentSurfaceInfo.changingToOriginalActive) {
|
||||
setTransparentSurfacesManager.setSurfaceToRegular (i, true);
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSurfacesToRemove ()
|
||||
{
|
||||
for (int i = 0; i < setTransparentSurfacesManager.surfaceInfoList.Count; i++) {
|
||||
currentSurfaceInfo = setTransparentSurfacesManager.surfaceInfoList [i];
|
||||
|
||||
if (currentSurfaceGameObjectFoundList.Contains (currentSurfaceInfo.surfaceGameObject)) {
|
||||
|
||||
if (currentSurfaceInfo.playerIDs.Contains (playerID)) {
|
||||
|
||||
setTransparentSurfacesManager.removePlayerIDToSurface (playerID, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSurfacesToTransparentOrRegularTemporaly (bool state)
|
||||
{
|
||||
for (int i = 0; i < setTransparentSurfacesManager.surfaceInfoList.Count; i++) {
|
||||
currentSurfaceInfo = setTransparentSurfacesManager.surfaceInfoList [i];
|
||||
|
||||
if (currentSurfaceGameObjectFoundList.Contains (currentSurfaceInfo.surfaceGameObject)) {
|
||||
|
||||
if (currentSurfaceInfo.playerIDs.Contains (playerID)) {
|
||||
|
||||
setTransparentSurfacesManager.changeSurfacesToTransparentOrRegularTemporaly (playerID, i, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCheckSurfaceActiveState (bool state)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkSurfaceActive = state;
|
||||
|
||||
if (!checkSurfaceActive) {
|
||||
|
||||
checkSurfacesToRemove ();
|
||||
|
||||
setTransparentSurfacesManager.checkSurfacesToRemove ();
|
||||
}
|
||||
|
||||
if (checkSurfaceActive) {
|
||||
if (useEventsOnStartCheckSurface) {
|
||||
eventOnStartCheckSurface.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (useEventsOnStopCheckSurface) {
|
||||
eventOnStopCheckSurface.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLockedCameraActiveState (bool state)
|
||||
{
|
||||
lockedCameraActive = state;
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo && Application.isPlaying && checkSurfaceActive) {
|
||||
|
||||
Gizmos.color = sphereColor;
|
||||
|
||||
Gizmos.DrawSphere (point1, capsuleCastRadius);
|
||||
Gizmos.DrawSphere (point2, capsuleCastRadius);
|
||||
|
||||
Gizmos.color = cubeColor;
|
||||
|
||||
Vector3 scale = new Vector3 (capsuleCastRadius * 2, capsuleCastRadius * 2, distanceToTarget - capsuleCastRadius * 2);
|
||||
|
||||
Matrix4x4 cubeTransform = Matrix4x4.TRS (((distanceToTarget / 2) * rayDirection) +
|
||||
currentRayTargetPosition.position,
|
||||
Quaternion.LookRotation (rayDirection, point1 - point2), scale);
|
||||
|
||||
Matrix4x4 oldGizmosMatrix = Gizmos.matrix;
|
||||
|
||||
Gizmos.matrix *= cubeTransform;
|
||||
|
||||
Gizmos.DrawCube (Vector3.zero, Vector3.one);
|
||||
|
||||
Gizmos.matrix = oldGizmosMatrix;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15cc78e4af696e94f99b606eee2b0242
|
||||
timeCreated: 1529702572
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Others/setTransparentSurfaces.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,363 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class setTransparentSurfacesSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkSurfaceEnabled = true;
|
||||
|
||||
public Shader transparentShader;
|
||||
public float alphaBlendSpeed = 5;
|
||||
public float alphaTransparency = 0.2f;
|
||||
|
||||
public bool useAlphaColor = true;
|
||||
public string transparentAmountName = "_TransparentAmount";
|
||||
|
||||
public string colorPropertyName = "_Color";
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public List<surfaceInfo> surfaceInfoList = new List<surfaceInfo> ();
|
||||
public List<GameObject> surfaceGameObjectList = new List<GameObject> ();
|
||||
|
||||
surfaceInfo newSurfaceInfo;
|
||||
materialInfo newMaterialInfo;
|
||||
|
||||
int transparentAmountID = -1;
|
||||
|
||||
|
||||
public const string mainManagerName = "Set Transparent Surfaces Manager";
|
||||
|
||||
public static string getMainManagerName ()
|
||||
{
|
||||
return mainManagerName;
|
||||
}
|
||||
|
||||
private static setTransparentSurfacesSystem _setTransparentSurfacesSystemInstance;
|
||||
|
||||
public static setTransparentSurfacesSystem Instance { get { return _setTransparentSurfacesSystemInstance; } }
|
||||
|
||||
bool instanceInitialized;
|
||||
|
||||
|
||||
public void getComponentInstance ()
|
||||
{
|
||||
if (instanceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_setTransparentSurfacesSystemInstance != null && _setTransparentSurfacesSystemInstance != this) {
|
||||
Destroy (this.gameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_setTransparentSurfacesSystemInstance = this;
|
||||
|
||||
instanceInitialized = true;
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
getComponentInstance ();
|
||||
}
|
||||
|
||||
public void addNewSurface (GameObject newSurface, Shader customShader)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
newSurfaceInfo = new surfaceInfo ();
|
||||
newSurfaceInfo.surfaceGameObject = newSurface;
|
||||
|
||||
Component[] components = newSurfaceInfo.surfaceGameObject.GetComponentsInChildren (typeof(Renderer));
|
||||
|
||||
int componentsLength = components.Length;
|
||||
|
||||
int colorID = Shader.PropertyToID (colorPropertyName);
|
||||
|
||||
for (int i = 0; i < componentsLength; i++) {
|
||||
Renderer child = components [i] as Renderer;
|
||||
|
||||
if (child.material.shader != null) {
|
||||
int materialsLength = child.materials.Length;
|
||||
|
||||
for (int j = 0; j < materialsLength; j++) {
|
||||
Material currentMaterial = child.materials [j];
|
||||
|
||||
newMaterialInfo = new materialInfo ();
|
||||
newMaterialInfo.surfaceMaterial = currentMaterial;
|
||||
|
||||
float colorValue = 1;
|
||||
|
||||
if (colorID != -1) {
|
||||
if (currentMaterial.HasProperty (colorID)) {
|
||||
Color alpha = currentMaterial.color;
|
||||
|
||||
colorValue = alpha.a;
|
||||
}
|
||||
}
|
||||
|
||||
newMaterialInfo.originalAlphaColor = colorValue;
|
||||
|
||||
newSurfaceInfo.materialInfoList.Add (newMaterialInfo);
|
||||
newSurfaceInfo.originalShader.Add (currentMaterial.shader);
|
||||
|
||||
if (customShader != null) {
|
||||
currentMaterial.shader = customShader;
|
||||
|
||||
newSurfaceInfo.customShader = customShader;
|
||||
} else {
|
||||
currentMaterial.shader = transparentShader;
|
||||
|
||||
newSurfaceInfo.customShader = transparentShader;
|
||||
}
|
||||
|
||||
newSurfaceInfo.materialsAmount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSurfaceTransparent (newSurfaceInfo);
|
||||
|
||||
surfaceInfoList.Add (newSurfaceInfo);
|
||||
|
||||
surfaceGameObjectList.Add (newSurfaceInfo.surfaceGameObject);
|
||||
}
|
||||
|
||||
public bool listContainsSurface (GameObject surfaceToCheck)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (surfaceGameObjectList.Contains (surfaceToCheck)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setSurfaceToRegular (int surfaceIndex, bool removeSurfaceAtEnd)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
surfaceInfo currentSurfaceToCheck = surfaceInfoList [surfaceIndex];
|
||||
|
||||
currentSurfaceToCheck.changingToOriginalActive = true;
|
||||
currentSurfaceToCheck.currentMaterialsChangedAmount = 0;
|
||||
currentSurfaceToCheck.changingToTransparentActive = false;
|
||||
|
||||
currentSurfaceToCheck.changingToOriginalTemporaly = !removeSurfaceAtEnd;
|
||||
|
||||
for (int j = 0; j < currentSurfaceToCheck.materialInfoList.Count; j++) {
|
||||
setAlphaValue (currentSurfaceToCheck, j, currentSurfaceToCheck.materialInfoList [j].surfaceMaterial,
|
||||
false, currentSurfaceToCheck.originalShader [j], currentSurfaceToCheck.materialInfoList [j].originalAlphaColor, removeSurfaceAtEnd);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSurfaceToSetTransparentAgain (GameObject surfaceToCheck)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int surfaceIndex = surfaceGameObjectList.IndexOf (surfaceToCheck);
|
||||
|
||||
if (surfaceIndex > -1) {
|
||||
surfaceInfo currentSurfaceToCheck = surfaceInfoList [surfaceIndex];
|
||||
|
||||
if (currentSurfaceToCheck.changingToOriginalActive && !currentSurfaceToCheck.changingToOriginalTemporaly) {
|
||||
// print ("changing to original, stopping");
|
||||
setSurfaceTransparent (currentSurfaceToCheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSurfaceTransparent (surfaceInfo currentSurfaceToCheck)
|
||||
{
|
||||
currentSurfaceToCheck.changingToOriginalActive = false;
|
||||
currentSurfaceToCheck.currentMaterialsChangedAmount = 0;
|
||||
currentSurfaceToCheck.changingToTransparentActive = true;
|
||||
|
||||
for (int j = 0; j < currentSurfaceToCheck.materialInfoList.Count; j++) {
|
||||
setAlphaValue (currentSurfaceToCheck, j, currentSurfaceToCheck.materialInfoList [j].surfaceMaterial,
|
||||
true, currentSurfaceToCheck.originalShader [j], currentSurfaceToCheck.materialInfoList [j].originalAlphaColor, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setAlphaValue (surfaceInfo currentSurfaceToCheck, int surfaceIndex, Material currentMaterial,
|
||||
bool changingToTransparent, Shader originalShader, float originalAlphaColor, bool removeSurfaceAtEnd)
|
||||
{
|
||||
if (currentSurfaceToCheck.materialInfoList [surfaceIndex].alphaBlendCoroutine != null) {
|
||||
StopCoroutine (currentSurfaceToCheck.materialInfoList [surfaceIndex].alphaBlendCoroutine);
|
||||
}
|
||||
|
||||
currentSurfaceToCheck.materialInfoList [surfaceIndex].alphaBlendCoroutine =
|
||||
StartCoroutine (setAlphaValueCoroutine (currentSurfaceToCheck, currentMaterial,
|
||||
changingToTransparent, originalShader, originalAlphaColor, removeSurfaceAtEnd));
|
||||
}
|
||||
|
||||
IEnumerator setAlphaValueCoroutine (surfaceInfo currentSurfaceToCheck, Material currentMaterial, bool changingToTransparent,
|
||||
Shader originalShader, float originalAlphaColor, bool removeSurfaceAtEnd)
|
||||
{
|
||||
float targetValue = originalAlphaColor;
|
||||
|
||||
if (changingToTransparent) {
|
||||
targetValue = alphaTransparency;
|
||||
|
||||
if (currentSurfaceToCheck.changingToOriginalTemporaly) {
|
||||
currentMaterial.shader = currentSurfaceToCheck.customShader;
|
||||
}
|
||||
}
|
||||
|
||||
if (useAlphaColor) {
|
||||
Color alpha = currentMaterial.color;
|
||||
|
||||
while (alpha.a != targetValue) {
|
||||
alpha.a = Mathf.MoveTowards (alpha.a, targetValue, Time.deltaTime * alphaBlendSpeed);
|
||||
currentMaterial.color = alpha;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
} else {
|
||||
if (transparentAmountID == -1) {
|
||||
transparentAmountID = Shader.PropertyToID (transparentAmountName);
|
||||
}
|
||||
|
||||
if (currentMaterial.HasProperty (transparentAmountID)) {
|
||||
|
||||
float currentTransparentAmount = currentMaterial.GetFloat (transparentAmountID);
|
||||
|
||||
while (currentTransparentAmount != targetValue) {
|
||||
currentTransparentAmount = Mathf.MoveTowards (currentTransparentAmount, targetValue, Time.deltaTime * alphaBlendSpeed);
|
||||
currentMaterial.SetFloat (transparentAmountID, currentTransparentAmount);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
} else {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!changingToTransparent) {
|
||||
currentMaterial.shader = originalShader;
|
||||
}
|
||||
|
||||
if (currentSurfaceToCheck.changingToOriginalActive) {
|
||||
currentSurfaceToCheck.currentMaterialsChangedAmount++;
|
||||
|
||||
if (removeSurfaceAtEnd) {
|
||||
if (currentSurfaceToCheck.currentMaterialsChangedAmount == currentSurfaceToCheck.materialsAmount) {
|
||||
surfaceInfoList.Remove (currentSurfaceToCheck);
|
||||
|
||||
surfaceGameObjectList.Remove (currentSurfaceToCheck.surfaceGameObject);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentSurfaceToCheck.currentMaterialsChangedAmount++;
|
||||
|
||||
if (currentSurfaceToCheck.currentMaterialsChangedAmount == currentSurfaceToCheck.materialsAmount) {
|
||||
currentSurfaceToCheck.changingToTransparentActive = false;
|
||||
|
||||
currentSurfaceToCheck.changingToOriginalTemporaly = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSurfacesToRemove ()
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < surfaceInfoList.Count; i++) {
|
||||
surfaceInfo currentSurfaceToCheck = surfaceInfoList [i];
|
||||
|
||||
if (currentSurfaceToCheck.numberOfPlayersFound == 0) {
|
||||
setSurfaceToRegular (i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSurfacesToTransparentOrRegularTemporaly (int playerID, int surfaceIndex, bool setTransparentSurface)
|
||||
{
|
||||
if (surfaceInfoList [surfaceIndex].playerIDs.Contains (playerID)) {
|
||||
if (setTransparentSurface) {
|
||||
// print ("transparent");
|
||||
setSurfaceTransparent (surfaceInfoList [surfaceIndex]);
|
||||
} else {
|
||||
// print ("regular");
|
||||
setSurfaceToRegular (surfaceIndex, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerIDToSurface (int playerID, GameObject surfaceToCheck)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < surfaceInfoList.Count; i++) {
|
||||
if (surfaceInfoList [i].surfaceGameObject == surfaceToCheck) {
|
||||
if (!surfaceInfoList [i].playerIDs.Contains (playerID)) {
|
||||
surfaceInfoList [i].playerIDs.Add (playerID);
|
||||
|
||||
surfaceInfoList [i].numberOfPlayersFound++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerIDToSurface (int playerID, int surfaceIndex)
|
||||
{
|
||||
if (!checkSurfaceEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (surfaceInfoList [surfaceIndex].playerIDs.Contains (playerID)) {
|
||||
surfaceInfoList [surfaceIndex].playerIDs.Remove (playerID);
|
||||
|
||||
surfaceInfoList [surfaceIndex].numberOfPlayersFound--;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class surfaceInfo
|
||||
{
|
||||
public GameObject surfaceGameObject;
|
||||
public List<Shader> originalShader = new List<Shader> ();
|
||||
public List<materialInfo> materialInfoList = new List<materialInfo> ();
|
||||
public List<int> playerIDs = new List<int> ();
|
||||
public int numberOfPlayersFound;
|
||||
|
||||
public bool changingToTransparentActive;
|
||||
public bool changingToOriginalActive;
|
||||
public bool changingToOriginalTemporaly;
|
||||
|
||||
public int materialsAmount;
|
||||
public int currentMaterialsChangedAmount;
|
||||
|
||||
public Shader customShader;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class materialInfo
|
||||
{
|
||||
public Material surfaceMaterial;
|
||||
public Coroutine alphaBlendCoroutine;
|
||||
public float originalAlphaColor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d8959f593f74574daf408f241e16f77
|
||||
timeCreated: 1551482151
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Others/setTransparentSurfacesSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,174 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class simpleMoveCameraToPosition : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cameraMovementActive = true;
|
||||
public bool smoothCameraMovement = true;
|
||||
|
||||
public bool useFixedLerpMovement = true;
|
||||
public float fixedLerpMovementSpeed = 2;
|
||||
|
||||
public float cameraMovementSpeedThirdPerson = 1;
|
||||
public float cameraMovementSpeedFirstPerson = 0.2f;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool movingCamera;
|
||||
public bool moveCameraActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject cameraPosition;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public GameObject currentPlayer;
|
||||
|
||||
public playerCamera playerCameraManager;
|
||||
|
||||
|
||||
Transform cameraParentTransform;
|
||||
Vector3 mainCameraTargetPosition;
|
||||
Quaternion mainCameraTargetRotation;
|
||||
Coroutine cameraState;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager;
|
||||
|
||||
|
||||
public void moveCamera (bool state)
|
||||
{
|
||||
moveCameraActive = state;
|
||||
|
||||
if (cameraPosition == null) {
|
||||
cameraPosition = gameObject;
|
||||
}
|
||||
|
||||
mainCameraTargetRotation = Quaternion.identity;
|
||||
mainCameraTargetPosition = Vector3.zero;
|
||||
|
||||
if (moveCameraActive) {
|
||||
if (cameraMovementActive) {
|
||||
if (cameraParentTransform == null) {
|
||||
cameraParentTransform = mainCamera.transform.parent;
|
||||
mainCamera.transform.SetParent (cameraPosition.transform);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if (cameraMovementActive) {
|
||||
if (cameraParentTransform != null) {
|
||||
mainCamera.transform.SetParent (cameraParentTransform);
|
||||
cameraParentTransform = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cameraMovementActive) {
|
||||
if (smoothCameraMovement) {
|
||||
stopMovement ();
|
||||
|
||||
cameraState = StartCoroutine (adjustCamera ());
|
||||
} else {
|
||||
mainCamera.transform.localRotation = mainCameraTargetRotation;
|
||||
mainCamera.transform.localPosition = mainCameraTargetPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator adjustCamera ()
|
||||
{
|
||||
movingCamera = true;
|
||||
|
||||
Transform mainCameraTransform = mainCamera.transform;
|
||||
|
||||
if (useFixedLerpMovement) {
|
||||
float i = 0;
|
||||
//store the current rotation of the camera
|
||||
Quaternion currentQ = mainCameraTransform.localRotation;
|
||||
//store the current position of the camera
|
||||
Vector3 currentPos = mainCameraTransform.localPosition;
|
||||
|
||||
//translate position and rotation camera
|
||||
while (i < 1) {
|
||||
i += Time.deltaTime * fixedLerpMovementSpeed;
|
||||
|
||||
mainCameraTransform.localRotation = Quaternion.Lerp (currentQ, mainCameraTargetRotation, i);
|
||||
mainCameraTransform.localPosition = Vector3.Lerp (currentPos, mainCameraTargetPosition, i);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
bool isFirstPersonActive = playerCameraManager.isFirstPersonActive ();
|
||||
|
||||
float currentCameraMovementSpeed = cameraMovementSpeedThirdPerson;
|
||||
|
||||
if (isFirstPersonActive) {
|
||||
currentCameraMovementSpeed = cameraMovementSpeedFirstPerson;
|
||||
}
|
||||
|
||||
float dist = GKC_Utils.distance (mainCameraTransform.localPosition, mainCameraTargetPosition);
|
||||
|
||||
float duration = dist / currentCameraMovementSpeed;
|
||||
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
float positionDifference = 0;
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime / duration;
|
||||
|
||||
mainCameraTransform.localPosition = Vector3.Lerp (mainCameraTransform.localPosition, mainCameraTargetPosition, t);
|
||||
mainCameraTransform.localRotation = Quaternion.Lerp (mainCameraTransform.localRotation, mainCameraTargetRotation, t);
|
||||
|
||||
angleDifference = Quaternion.Angle (mainCameraTransform.localRotation, mainCameraTargetRotation);
|
||||
|
||||
positionDifference = GKC_Utils.distance (mainCameraTransform.localPosition, mainCameraTargetPosition);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if ((positionDifference < 0.01f && angleDifference < 0.2f) || movementTimer > (duration + 1)) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
movingCamera = false;
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject player)
|
||||
{
|
||||
currentPlayer = player;
|
||||
|
||||
if (currentPlayer != null) {
|
||||
mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
mainCamera = playerCameraManager.getMainCamera ();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMovement ()
|
||||
{
|
||||
if (cameraState != null) {
|
||||
StopCoroutine (cameraState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36538b8ea8712ae4e919fb7a63513456
|
||||
timeCreated: 1662737835
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Others/simpleMoveCameraToPosition.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d411789375d18c341923f130f424182b
|
||||
folderAsset: yes
|
||||
timeCreated: 1504022644
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class camera2_5dSplineZoneOptions : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool camera2_5dSplineZoneEnabled = true;
|
||||
|
||||
public bool setFollowPlayerRotationDirectionPausedState;
|
||||
|
||||
public bool setFollowPlayerRotationDirectionPausedValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool adjustLockedCameraRotationToTransform;
|
||||
|
||||
public float adjustLockedCameraRotationSpeed = 10;
|
||||
|
||||
public Transform transformToAdjustLockedCameraRotation;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
|
||||
GameObject currentPlayer;
|
||||
|
||||
playerCamera currentPlayerCamera;
|
||||
|
||||
|
||||
public void setCurrentPlayerAndActivateCameraState (GameObject newPlayer)
|
||||
{
|
||||
setCurrentPlayer (newPlayer);
|
||||
|
||||
setCameraStateOnPlayer ();
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject newPlayer)
|
||||
{
|
||||
if (newPlayer == null) {
|
||||
print ("WARNING: the zone system is trying to assign an empty player, make sure the system is properly configured");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayer = newPlayer;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
currentPlayerCamera = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCameraStateOnPlayer ()
|
||||
{
|
||||
if (!camera2_5dSplineZoneEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPlayerCamera == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (setFollowPlayerRotationDirectionPausedState) {
|
||||
currentPlayerCamera.setFollowPlayerRotationDirectionEnabledOnLockedCameraPausedState (setFollowPlayerRotationDirectionPausedValue);
|
||||
}
|
||||
|
||||
if (adjustLockedCameraRotationToTransform) {
|
||||
currentPlayerCamera.setLockedMainCameraTransformRotationSmoothly (transformToAdjustLockedCameraRotation.eulerAngles, adjustLockedCameraRotationSpeed);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("player detected, setting camera state");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fbe110e5a841d647a0c930ffacbdec0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/camera2_5dSplineZoneOptions.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,249 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class camera2_5dZoneLimitSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useCameraLimit = true;
|
||||
|
||||
public bool setCameraForwardPosition;
|
||||
public float cameraForwardPosition;
|
||||
|
||||
public bool useMoveInXAxisOn2_5d;
|
||||
|
||||
[Space]
|
||||
[Header ("Limit Width Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useWidthLimit = true;
|
||||
public float widthLimitRight;
|
||||
public float widthLimitLeft;
|
||||
|
||||
[Space]
|
||||
[Header ("Limit Height Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useHeightLimit = true;
|
||||
public float heightLimitUpper;
|
||||
public float heightLimitLower;
|
||||
|
||||
[Space]
|
||||
[Header ("Limit Depth Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useDepthLimit;
|
||||
public float depthLimitFront;
|
||||
public float depthLimitBackward;
|
||||
|
||||
[Space]
|
||||
[Header ("Set Limit At Start Settings")]
|
||||
[Space]
|
||||
|
||||
public bool startGameWithThisLimit;
|
||||
public GameObject playerForView;
|
||||
public bool useMultiplePlayers;
|
||||
public List<GameObject> playerForViewList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Gizmo Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showGizmo;
|
||||
public Color gizmoColor = Color.white;
|
||||
public float gizmoRadius = 0.2f;
|
||||
public Color depthGizmoColor = Color.white;
|
||||
|
||||
Vector3 currentPosition;
|
||||
|
||||
GameObject currentPlayer;
|
||||
|
||||
Vector3 horizontalRightUpperLinePosition;
|
||||
Vector3 horizontalLeftUpperLinePosition;
|
||||
Vector3 horizontalRightLowerLinePosition;
|
||||
Vector3 horizontalLeftLowerLinePosition;
|
||||
Vector3 verticalRightUpperLinePosition;
|
||||
Vector3 verticalRightLowerLinePosition;
|
||||
Vector3 verticalLeftUpperLinePosition;
|
||||
Vector3 verticalLefttLowerLinePosition;
|
||||
|
||||
Vector3 depthFrontPosition;
|
||||
Vector3 depthBackwardPosition;
|
||||
|
||||
float totalWidth;
|
||||
float totalheight;
|
||||
|
||||
playerController playerControlerManager;
|
||||
playerCamera playerCameraManager;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (startGameWithThisLimit) {
|
||||
if (useMultiplePlayers) {
|
||||
for (int k = 0; k < playerForViewList.Count; k++) {
|
||||
setCurrentPlayer (playerForViewList [k]);
|
||||
|
||||
setCameraLimitOnPlayer ();
|
||||
}
|
||||
} else {
|
||||
setCurrentPlayer (playerForView);
|
||||
|
||||
setCameraLimitOnPlayer ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCameraLimitOnPlayer ()
|
||||
{
|
||||
if (currentPlayer != null) {
|
||||
playerCameraManager.setCameraLimit (useCameraLimit, useWidthLimit, widthLimitRight, widthLimitLeft, useHeightLimit, heightLimitUpper,
|
||||
heightLimitLower, transform.position, useDepthLimit, depthLimitFront, depthLimitBackward);
|
||||
|
||||
if (setCameraForwardPosition) {
|
||||
playerCameraManager.setNewCameraForwardPosition (cameraForwardPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCameraLimitOnPlayer (GameObject newPlayer)
|
||||
{
|
||||
setCurrentPlayer (newPlayer);
|
||||
|
||||
setCameraLimitOnPlayer ();
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject newPlayer)
|
||||
{
|
||||
if (newPlayer == null) {
|
||||
print ("WARNING: the zone limit system is trying to assign an empty player, make sure the system is properly configured");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayer = newPlayer;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
playerControlerManager = mainPlayerComponentsManager.getPlayerController ();
|
||||
}
|
||||
|
||||
if (playerControlerManager != null && mainPlayerComponentsManager != null) {
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
} else {
|
||||
vehicleHUDManager currentVehicleHUDManager = applyDamage.getVehicleHUDManager (newPlayer);
|
||||
|
||||
if (currentVehicleHUDManager != null && currentVehicleHUDManager.isVehicleBeingDriven ()) {
|
||||
|
||||
currentPlayer = currentVehicleHUDManager.getCurrentDriver ();
|
||||
|
||||
mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
playerControlerManager = mainPlayerComponentsManager.getPlayerController ();
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfigurationToPlayer ()
|
||||
{
|
||||
setCameraLimitOnPlayer ();
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
|
||||
currentPosition = transform.position;
|
||||
|
||||
horizontalRightUpperLinePosition = currentPosition + Vector3.up * heightLimitUpper;
|
||||
horizontalLeftUpperLinePosition = currentPosition + Vector3.up * heightLimitUpper;
|
||||
horizontalRightLowerLinePosition = currentPosition - Vector3.up * heightLimitLower;
|
||||
horizontalLeftLowerLinePosition = currentPosition - Vector3.up * heightLimitLower;
|
||||
verticalRightUpperLinePosition = currentPosition + Vector3.up * heightLimitUpper;
|
||||
verticalRightLowerLinePosition = currentPosition - Vector3.up * heightLimitLower;
|
||||
verticalLeftUpperLinePosition = currentPosition + Vector3.up * heightLimitUpper;
|
||||
verticalLefttLowerLinePosition = currentPosition - Vector3.up * heightLimitLower;
|
||||
|
||||
if (useMoveInXAxisOn2_5d) {
|
||||
horizontalRightUpperLinePosition += Vector3.right * widthLimitRight;
|
||||
horizontalLeftUpperLinePosition -= Vector3.right * widthLimitLeft;
|
||||
horizontalRightLowerLinePosition += Vector3.right * widthLimitRight;
|
||||
horizontalLeftLowerLinePosition -= Vector3.right * widthLimitLeft;
|
||||
verticalRightUpperLinePosition += Vector3.right * widthLimitRight;
|
||||
verticalRightLowerLinePosition += Vector3.right * widthLimitRight;
|
||||
verticalLeftUpperLinePosition -= Vector3.right * widthLimitLeft;
|
||||
verticalLefttLowerLinePosition -= Vector3.right * widthLimitLeft;
|
||||
} else {
|
||||
horizontalRightUpperLinePosition += Vector3.forward * widthLimitRight;
|
||||
horizontalLeftUpperLinePosition -= Vector3.forward * widthLimitLeft;
|
||||
horizontalRightLowerLinePosition += Vector3.forward * widthLimitRight;
|
||||
horizontalLeftLowerLinePosition -= Vector3.forward * widthLimitLeft;
|
||||
verticalRightUpperLinePosition += Vector3.forward * widthLimitRight;
|
||||
verticalRightLowerLinePosition += Vector3.forward * widthLimitRight;
|
||||
verticalLeftUpperLinePosition -= Vector3.forward * widthLimitLeft;
|
||||
verticalLefttLowerLinePosition -= Vector3.forward * widthLimitLeft;
|
||||
}
|
||||
|
||||
Gizmos.DrawCube (transform.position, Vector3.one * gizmoRadius);
|
||||
|
||||
if (useWidthLimit) {
|
||||
Gizmos.DrawLine (horizontalRightUpperLinePosition, horizontalLeftUpperLinePosition);
|
||||
Gizmos.DrawLine (horizontalRightLowerLinePosition, horizontalLeftLowerLinePosition);
|
||||
}
|
||||
|
||||
if (useHeightLimit) {
|
||||
Gizmos.DrawLine (verticalRightUpperLinePosition, verticalRightLowerLinePosition);
|
||||
Gizmos.DrawLine (verticalLeftUpperLinePosition, verticalLefttLowerLinePosition);
|
||||
}
|
||||
|
||||
if (useDepthLimit) {
|
||||
Gizmos.color = depthGizmoColor;
|
||||
|
||||
totalWidth = widthLimitRight + widthLimitLeft;
|
||||
totalheight = heightLimitUpper + heightLimitLower;
|
||||
|
||||
if (useMoveInXAxisOn2_5d) {
|
||||
depthFrontPosition = transform.position + Vector3.forward * depthLimitFront / 2 + Vector3.right * widthLimitRight / 2 - Vector3.right * widthLimitLeft / 2;
|
||||
depthFrontPosition += Vector3.up * heightLimitUpper / 2 - Vector3.up * heightLimitLower / 2;
|
||||
|
||||
Gizmos.DrawCube (depthFrontPosition, new Vector3 (totalWidth, totalheight, depthLimitFront));
|
||||
|
||||
depthBackwardPosition = transform.position - Vector3.forward * depthLimitBackward / 2 + Vector3.right * widthLimitRight / 2 - Vector3.right * widthLimitLeft / 2;
|
||||
depthBackwardPosition += Vector3.up * heightLimitUpper / 2 - Vector3.up * heightLimitLower / 2;
|
||||
|
||||
Gizmos.DrawCube (depthBackwardPosition, new Vector3 (totalWidth, totalheight, depthLimitBackward));
|
||||
} else {
|
||||
|
||||
depthFrontPosition = transform.position + Vector3.right * depthLimitFront / 2 + Vector3.forward * widthLimitRight / 2 - Vector3.forward * widthLimitLeft / 2;
|
||||
depthFrontPosition += Vector3.up * heightLimitUpper / 2 - Vector3.up * heightLimitLower / 2;
|
||||
|
||||
Gizmos.DrawCube (depthFrontPosition, new Vector3 (depthLimitFront, totalheight, totalWidth));
|
||||
|
||||
depthBackwardPosition = transform.position - Vector3.right * depthLimitBackward / 2 + Vector3.forward * widthLimitRight / 2 - Vector3.forward * widthLimitLeft / 2;
|
||||
depthBackwardPosition += Vector3.up * heightLimitUpper / 2 - Vector3.up * heightLimitLower / 2;
|
||||
|
||||
Gizmos.DrawCube (depthBackwardPosition, new Vector3 (depthLimitBackward, totalheight, totalWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c63dbd328947b1745b33b0e540eee285
|
||||
timeCreated: 1541957881
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/camera2_5dZoneLimitSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class cameraAxisComponentsInfo : MonoBehaviour {
|
||||
public lockedCameraSystem.cameraAxis cameraAxisInfo;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9fd7d9d85f3edd47ae187e1b67c2374
|
||||
timeCreated: 1508683520
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/cameraAxisComponentsInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,182 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class cameraControllerManager : MonoBehaviour
|
||||
{
|
||||
public virtual bool isFirstPersonActive ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool isMoveInXAxisOn2_5d ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void setMoveInXAxisOn2_5dState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual Vector3 getOriginalLockedCameraPivotPosition ()
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
public virtual Vector3 getSplineForPlayerPosition (Vector3 playerPosition)
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
public virtual Vector3 getSplineForwardDirection (Vector3 playerPosition)
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
public virtual void changeCameraFov (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual Transform getPivotCameraTransform ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual Transform getLockedCameraTransform ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void crouch (bool isCrouching)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setMainCameraFovStartAndEnd (float startTargetValue, float endTargetValue, float speed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual float getOriginalCameraFov ()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public virtual bool isPlayerLookingAtTarget ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool isLookintAtTargetByInput ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void setShakeCameraState (bool state, string stateName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual float getLastTimeMoved ()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public virtual void setDrivingState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool is2_5ViewActive ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool istargetToLookLocated ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void setPlayerAndCameraParent (Transform newParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void stopShakeCamera ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual Transform getCurrentTargetToLook ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void setUpdatePlayerCameraPositionOnLateUpdateActiveState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setUpdatePlayerCameraPositionOnFixedUpdateActiveState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool isFullBodyAwarenessEnabled ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void setPivotCameraTransformParentCurrentTransformToFollow ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setPivotCameraTransformOriginalParent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void resetPivotCameraTransformLocalRotation ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setHeadColliderStateOnFBA (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setFBAPivotCameraTransformActiveState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void startOrStopUpdatePivotPositionOnFBA (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkActivateOrDeactivateHeadColliderOnFBA (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkResetLeanState (bool resetPivotCameraTransform)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool isShowCameraCursorWhenNotAimingActive ()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void setFBAPivotTransformParentFromPlayer (Transform newParent)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c78e484febad1f4428cca9239634eef4
|
||||
timeCreated: 1631151176
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/cameraControllerManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,212 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[System.Serializable]
|
||||
public class cameraStateInfo
|
||||
{
|
||||
public string Name;
|
||||
public Vector3 camPositionOffset;
|
||||
public Vector3 pivotPositionOffset;
|
||||
public Vector3 pivotParentPositionOffset;
|
||||
public Vector2 yLimits;
|
||||
|
||||
public float initialFovValue;
|
||||
public float fovTransitionSpeed = 10;
|
||||
|
||||
public float maxFovValue;
|
||||
public float minFovValue = 17;
|
||||
|
||||
public bool showGizmo;
|
||||
public Color gizmoColor;
|
||||
|
||||
public Vector3 originalCamPositionOffset;
|
||||
|
||||
public bool leanEnabled;
|
||||
public float maxLeanAngle;
|
||||
public float leanSpeed;
|
||||
public float leanResetSpeed;
|
||||
public float leanRaycastDistance;
|
||||
public float leanAngleOnSurfaceFound;
|
||||
public float leanHeight;
|
||||
|
||||
public bool isLeanOnFBA;
|
||||
public float FBALeanPositionOffsetX;
|
||||
public float FBALeanPositionOffsetY;
|
||||
|
||||
public bool headTrackActive = true;
|
||||
|
||||
public bool lookInPlayerDirection;
|
||||
public float lookInPlayerDirectionSpeed;
|
||||
public bool allowRotationWithInput;
|
||||
public float timeToResetRotationAfterInput;
|
||||
|
||||
public bool useYLimitsOnLookAtTargetActive;
|
||||
public Vector2 YLimitsOnLookAtTargetActive = new Vector2 (-20, 30);
|
||||
|
||||
public bool cameraCollisionActive = true;
|
||||
|
||||
public float pivotRotationOffset;
|
||||
|
||||
public bool ignoreCameraShakeOnRunState;
|
||||
|
||||
public bool followTransformPosition;
|
||||
public Transform transformToFollow;
|
||||
public bool useFollowTransformPositionOffset;
|
||||
public Vector3 followTransformPositionOffset;
|
||||
|
||||
public bool setNearClipPlaneValue;
|
||||
public float nearClipPlaneValue;
|
||||
|
||||
public bool useCustomMovementLerpSpeed;
|
||||
|
||||
public float movementLerpSpeed = 5;
|
||||
|
||||
|
||||
|
||||
public cameraStateInfo (cameraStateInfo newState)
|
||||
{
|
||||
Name = newState.Name;
|
||||
|
||||
camPositionOffset = newState.camPositionOffset;
|
||||
pivotPositionOffset = newState.pivotPositionOffset;
|
||||
pivotParentPositionOffset = newState.pivotParentPositionOffset;
|
||||
|
||||
yLimits = newState.yLimits;
|
||||
|
||||
initialFovValue = newState.initialFovValue;
|
||||
fovTransitionSpeed = newState.fovTransitionSpeed;
|
||||
maxFovValue = newState.maxFovValue;
|
||||
minFovValue = newState.minFovValue;
|
||||
|
||||
originalCamPositionOffset = newState.originalCamPositionOffset;
|
||||
|
||||
leanEnabled = newState.leanEnabled;
|
||||
maxLeanAngle = newState.maxLeanAngle;
|
||||
leanSpeed = newState.leanSpeed;
|
||||
leanResetSpeed = newState.leanResetSpeed;
|
||||
leanRaycastDistance = newState.leanRaycastDistance;
|
||||
leanAngleOnSurfaceFound = newState.leanAngleOnSurfaceFound;
|
||||
leanHeight = newState.leanHeight;
|
||||
|
||||
isLeanOnFBA = newState.isLeanOnFBA;
|
||||
FBALeanPositionOffsetX = newState.FBALeanPositionOffsetX;
|
||||
FBALeanPositionOffsetY = newState.FBALeanPositionOffsetY;
|
||||
|
||||
headTrackActive = newState.headTrackActive;
|
||||
|
||||
lookInPlayerDirection = newState.lookInPlayerDirection;
|
||||
lookInPlayerDirectionSpeed = newState.lookInPlayerDirectionSpeed;
|
||||
allowRotationWithInput = newState.allowRotationWithInput;
|
||||
timeToResetRotationAfterInput = newState.timeToResetRotationAfterInput;
|
||||
|
||||
useYLimitsOnLookAtTargetActive = newState.useYLimitsOnLookAtTargetActive;
|
||||
YLimitsOnLookAtTargetActive = newState.YLimitsOnLookAtTargetActive;
|
||||
|
||||
cameraCollisionActive = newState.cameraCollisionActive;
|
||||
|
||||
pivotRotationOffset = newState.pivotRotationOffset;
|
||||
|
||||
ignoreCameraShakeOnRunState = newState.ignoreCameraShakeOnRunState;
|
||||
|
||||
followTransformPosition = newState.followTransformPosition;
|
||||
transformToFollow = newState.transformToFollow;
|
||||
|
||||
useFollowTransformPositionOffset = newState.useFollowTransformPositionOffset;
|
||||
followTransformPositionOffset = newState.followTransformPositionOffset;
|
||||
|
||||
setNearClipPlaneValue = newState.setNearClipPlaneValue;
|
||||
nearClipPlaneValue = newState.nearClipPlaneValue;
|
||||
|
||||
useCustomMovementLerpSpeed = newState.useCustomMovementLerpSpeed;
|
||||
movementLerpSpeed = newState.movementLerpSpeed;
|
||||
}
|
||||
|
||||
public void assignCameraStateValues (cameraStateInfo from, float lerpSpeed)
|
||||
{
|
||||
Name = from.Name;
|
||||
|
||||
if (lerpSpeed > 0) {
|
||||
if (camPositionOffset != from.camPositionOffset) {
|
||||
camPositionOffset = Vector3.Lerp (camPositionOffset, from.camPositionOffset, lerpSpeed);
|
||||
}
|
||||
|
||||
if (pivotPositionOffset != from.pivotPositionOffset) {
|
||||
pivotPositionOffset = Vector3.Lerp (pivotPositionOffset, from.pivotPositionOffset, lerpSpeed);
|
||||
}
|
||||
|
||||
if (pivotParentPositionOffset != from.pivotParentPositionOffset) {
|
||||
pivotParentPositionOffset = Vector3.Lerp (pivotParentPositionOffset, from.pivotParentPositionOffset, lerpSpeed);
|
||||
}
|
||||
|
||||
if (yLimits.x != from.yLimits.x) {
|
||||
yLimits.x = Mathf.Lerp (yLimits.x, from.yLimits.x, lerpSpeed);
|
||||
}
|
||||
|
||||
if (yLimits.y != from.yLimits.y) {
|
||||
yLimits.y = Mathf.Lerp (yLimits.y, from.yLimits.y, lerpSpeed);
|
||||
}
|
||||
} else {
|
||||
camPositionOffset = from.camPositionOffset;
|
||||
pivotPositionOffset = from.pivotPositionOffset;
|
||||
pivotParentPositionOffset = from.pivotParentPositionOffset;
|
||||
|
||||
yLimits = from.yLimits;
|
||||
}
|
||||
|
||||
initialFovValue = from.initialFovValue;
|
||||
fovTransitionSpeed = from.fovTransitionSpeed;
|
||||
maxFovValue = from.maxFovValue;
|
||||
minFovValue = from.minFovValue;
|
||||
|
||||
originalCamPositionOffset = from.originalCamPositionOffset;
|
||||
|
||||
leanEnabled = from.leanEnabled;
|
||||
maxLeanAngle = from.maxLeanAngle;
|
||||
leanSpeed = from.leanSpeed;
|
||||
leanResetSpeed = from.leanResetSpeed;
|
||||
leanRaycastDistance = from.leanRaycastDistance;
|
||||
leanAngleOnSurfaceFound = from.leanAngleOnSurfaceFound;
|
||||
leanHeight = from.leanHeight;
|
||||
|
||||
if (leanEnabled) {
|
||||
isLeanOnFBA = from.isLeanOnFBA;
|
||||
FBALeanPositionOffsetX = from.FBALeanPositionOffsetX;
|
||||
FBALeanPositionOffsetY = from.FBALeanPositionOffsetY;
|
||||
}
|
||||
|
||||
headTrackActive = from.headTrackActive;
|
||||
|
||||
lookInPlayerDirection = from.lookInPlayerDirection;
|
||||
lookInPlayerDirectionSpeed = from.lookInPlayerDirectionSpeed;
|
||||
allowRotationWithInput = from.allowRotationWithInput;
|
||||
timeToResetRotationAfterInput = from.timeToResetRotationAfterInput;
|
||||
|
||||
useYLimitsOnLookAtTargetActive = from.useYLimitsOnLookAtTargetActive;
|
||||
YLimitsOnLookAtTargetActive = from.YLimitsOnLookAtTargetActive;
|
||||
|
||||
cameraCollisionActive = from.cameraCollisionActive;
|
||||
|
||||
pivotRotationOffset = from.pivotRotationOffset;
|
||||
|
||||
ignoreCameraShakeOnRunState = from.ignoreCameraShakeOnRunState;
|
||||
|
||||
followTransformPosition = from.followTransformPosition;
|
||||
transformToFollow = from.transformToFollow;
|
||||
|
||||
useFollowTransformPositionOffset = from.useFollowTransformPositionOffset;
|
||||
followTransformPositionOffset = from.followTransformPositionOffset;
|
||||
|
||||
setNearClipPlaneValue = from.setNearClipPlaneValue;
|
||||
|
||||
if (setNearClipPlaneValue) {
|
||||
nearClipPlaneValue = from.nearClipPlaneValue;
|
||||
}
|
||||
|
||||
useCustomMovementLerpSpeed = from.useCustomMovementLerpSpeed;
|
||||
|
||||
if (useCustomMovementLerpSpeed) {
|
||||
movementLerpSpeed = from.movementLerpSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d7d5de32a5418b41a978deed5518cb6
|
||||
timeCreated: 1470673329
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/cameraStateInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,280 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class externalCameraShakeSystem : MonoBehaviour
|
||||
{
|
||||
public bool externalCameraShakeEnabled = true;
|
||||
|
||||
public string externalShakeName;
|
||||
public bool shakeUsingDistance;
|
||||
public float minDistanceToShake;
|
||||
public LayerMask layer;
|
||||
public bool useShakeListTriggeredByActions;
|
||||
public List<shakeTriggeredByActionInfo> shakeTriggeredByActionList = new List<shakeTriggeredByActionInfo> ();
|
||||
|
||||
public bool useShakeEvent;
|
||||
public UnityEvent eventAtStart;
|
||||
public UnityEvent eventAtEnd;
|
||||
|
||||
bool currentUseShakeEventValue;
|
||||
UnityEvent currentEventAtStart;
|
||||
UnityEvent currentEventAtEnd;
|
||||
|
||||
public bool setPlayerManually;
|
||||
public GameObject currentPlayer;
|
||||
|
||||
public string mainManagerName = "External Shake List Manager";
|
||||
|
||||
public bool showGizmo;
|
||||
public Color gizmoLabelColor = Color.black;
|
||||
public int nameIndex;
|
||||
public string [] nameList;
|
||||
|
||||
public externalShakeListManager externalShakeManager;
|
||||
|
||||
float distancePercentage;
|
||||
headBob headBobManager;
|
||||
|
||||
bool playerAssignedManually;
|
||||
|
||||
public void getExternalShakeList ()
|
||||
{
|
||||
bool externalShakeManagerLocated = false;
|
||||
|
||||
if (Application.isPlaying) {
|
||||
externalShakeManagerLocated = externalShakeManager != null;
|
||||
|
||||
if (!externalShakeManagerLocated) {
|
||||
externalShakeManager = externalShakeListManager.Instance;
|
||||
|
||||
externalShakeManagerLocated = externalShakeManager != null;
|
||||
}
|
||||
|
||||
if (!externalShakeManagerLocated) {
|
||||
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (externalShakeListManager.getMainManagerName (), typeof (externalShakeListManager), true);
|
||||
|
||||
externalShakeManager = externalShakeListManager.Instance;
|
||||
|
||||
externalShakeManagerLocated = externalShakeManager != null;
|
||||
}
|
||||
} else {
|
||||
externalShakeManagerLocated = externalShakeManager != null;
|
||||
|
||||
if (!externalShakeManagerLocated) {
|
||||
externalShakeManager = FindObjectOfType<externalShakeListManager> ();
|
||||
|
||||
externalShakeManagerLocated = externalShakeManager != null;
|
||||
}
|
||||
|
||||
if (!externalShakeManagerLocated) {
|
||||
GKC_Utils.instantiateMainManagerOnSceneWithType (externalShakeListManager.getMainManagerName (), typeof (externalShakeListManager));
|
||||
|
||||
externalShakeManager = FindObjectOfType<externalShakeListManager> ();
|
||||
|
||||
externalShakeManagerLocated = externalShakeManager != null;
|
||||
}
|
||||
}
|
||||
|
||||
if (externalShakeManagerLocated) {
|
||||
nameList = new string [externalShakeManager.externalShakeInfoList.Count];
|
||||
|
||||
for (int i = 0; i < externalShakeManager.externalShakeInfoList.Count; i++) {
|
||||
nameList [i] = externalShakeManager.externalShakeInfoList [i].name;
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject player)
|
||||
{
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayer = player;
|
||||
|
||||
if (headBobManager == null) {
|
||||
playerComponentsManager mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
headBobManager = mainPlayerComponentsManager.getHeadBob ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPlayerAndActivateCameraShake (GameObject player)
|
||||
{
|
||||
setCurrentPlayer (player);
|
||||
|
||||
setCameraShake ();
|
||||
}
|
||||
|
||||
public void setCameraShake ()
|
||||
{
|
||||
if (!externalCameraShakeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentUseShakeEventValue = useShakeEvent;
|
||||
|
||||
if (currentUseShakeEventValue) {
|
||||
currentEventAtStart = eventAtStart;
|
||||
currentEventAtEnd = eventAtEnd;
|
||||
}
|
||||
|
||||
if (setPlayerManually) {
|
||||
if (!playerAssignedManually) {
|
||||
setCurrentPlayer (currentPlayer);
|
||||
|
||||
playerAssignedManually = true;
|
||||
}
|
||||
}
|
||||
|
||||
setCameraShakeByName (externalShakeName);
|
||||
|
||||
currentUseShakeEventValue = false;
|
||||
}
|
||||
|
||||
public void setCameraShakeByAction (string actionName)
|
||||
{
|
||||
if (!externalCameraShakeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int shakeTriggeredByActionListCount = shakeTriggeredByActionList.Count;
|
||||
|
||||
for (int i = 0; i < shakeTriggeredByActionListCount; i++) {
|
||||
if (shakeTriggeredByActionList [i].actionName.Equals (actionName)) {
|
||||
|
||||
currentUseShakeEventValue = shakeTriggeredByActionList [i].useShakeEvent;
|
||||
|
||||
if (currentUseShakeEventValue) {
|
||||
currentEventAtStart = shakeTriggeredByActionList [i].eventAtStart;
|
||||
currentEventAtEnd = shakeTriggeredByActionList [i].eventAtEnd;
|
||||
}
|
||||
|
||||
setPlayerManually = true;
|
||||
|
||||
if (setPlayerManually) {
|
||||
setCurrentPlayer (currentPlayer);
|
||||
}
|
||||
|
||||
setCameraShakeByName (shakeTriggeredByActionList [i].shakeName);
|
||||
|
||||
currentUseShakeEventValue = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCameraShakeByName (string shakeName)
|
||||
{
|
||||
if (!externalCameraShakeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (setPlayerManually) {
|
||||
if (currentPlayer != null) {
|
||||
setExternalShakeSignal (currentPlayer, shakeName);
|
||||
}
|
||||
} else {
|
||||
List<Collider> colliders = new List<Collider> ();
|
||||
|
||||
colliders.AddRange (Physics.OverlapSphere (transform.position, minDistanceToShake, layer));
|
||||
|
||||
int collidersCount = colliders.Count;
|
||||
|
||||
for (int i = 0; i < collidersCount; i++) {
|
||||
Collider hit = colliders [i];
|
||||
|
||||
if (hit != null && !hit.isTrigger) {
|
||||
setExternalShakeSignal (hit.gameObject, shakeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setExternalShakeSignal (GameObject objectToCall, string shakeName)
|
||||
{
|
||||
if (!externalCameraShakeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shakeUsingDistance) {
|
||||
float currentDistance = GKC_Utils.distance (objectToCall.transform.position, transform.position);
|
||||
|
||||
if (currentDistance <= minDistanceToShake) {
|
||||
distancePercentage = currentDistance / minDistanceToShake;
|
||||
distancePercentage = 1 - distancePercentage;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
distancePercentage = 1;
|
||||
}
|
||||
|
||||
if (!setPlayerManually) {
|
||||
playerComponentsManager mainPlayerComponentsManager = objectToCall.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
headBobManager = mainPlayerComponentsManager.getHeadBob ();
|
||||
}
|
||||
}
|
||||
|
||||
if (headBobManager != null) {
|
||||
if (currentUseShakeEventValue) {
|
||||
headBobManager.setCurrentExternalCameraShakeSystemEvents (currentEventAtStart, currentEventAtEnd);
|
||||
} else {
|
||||
headBobManager.disableUseShakeEventState ();
|
||||
}
|
||||
|
||||
headBobManager.setExternalShakeStateByName (shakeName, distancePercentage);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Updating External Camera Shake System ", gameObject);
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere (transform.position, minDistanceToShake);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class shakeTriggeredByActionInfo
|
||||
{
|
||||
public string actionName;
|
||||
public string shakeName;
|
||||
public int nameIndex;
|
||||
|
||||
public bool useShakeEvent;
|
||||
public UnityEvent eventAtStart;
|
||||
public UnityEvent eventAtEnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1688134050b0e8a4b86b67ac8cc8f30e
|
||||
timeCreated: 1501357091
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/externalCameraShakeSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[System.Serializable]
|
||||
public class externalShakeInfo
|
||||
{
|
||||
|
||||
public Vector3 shakePosition;
|
||||
public Vector3 shakePositionSpeed;
|
||||
public float shakePositionSmooth;
|
||||
public Vector3 shakeRotation;
|
||||
public Vector3 shakeRotationSpeed;
|
||||
public float shakeRotationSmooth;
|
||||
public float shakeDuration;
|
||||
|
||||
public bool decreaseShakeInTime;
|
||||
public float decreaseShakeSpeed;
|
||||
|
||||
public bool useDelayBeforeStartDecrease;
|
||||
public float delayBeforeStartDecrease;
|
||||
|
||||
public bool repeatShake;
|
||||
public int numberOfRepeats;
|
||||
public float delayBetweenRepeats;
|
||||
|
||||
public float externalShakeDelay;
|
||||
|
||||
public bool useUnscaledTime;
|
||||
|
||||
public externalShakeInfo (externalShakeInfo newShake)
|
||||
{
|
||||
shakePosition = newShake.shakePosition;
|
||||
shakePositionSpeed = newShake.shakePositionSpeed;
|
||||
shakePositionSmooth = newShake.shakePositionSmooth;
|
||||
shakeRotation = newShake.shakeRotation;
|
||||
shakeRotationSpeed = newShake.shakeRotationSpeed;
|
||||
shakeRotationSmooth = newShake.shakeRotationSmooth;
|
||||
shakeDuration = newShake.shakeDuration;
|
||||
decreaseShakeInTime = newShake.decreaseShakeInTime;
|
||||
decreaseShakeSpeed = newShake.decreaseShakeSpeed;
|
||||
|
||||
useDelayBeforeStartDecrease = newShake.useDelayBeforeStartDecrease;
|
||||
delayBeforeStartDecrease = newShake.delayBeforeStartDecrease;
|
||||
|
||||
repeatShake = newShake.repeatShake;
|
||||
numberOfRepeats = newShake.numberOfRepeats;
|
||||
delayBetweenRepeats = newShake.delayBetweenRepeats;
|
||||
|
||||
externalShakeDelay = newShake.externalShakeDelay;
|
||||
|
||||
useUnscaledTime = newShake.useUnscaledTime;
|
||||
}
|
||||
|
||||
public externalShakeInfo ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3a997b6c44b057409b6311ab9163557
|
||||
timeCreated: 1514422036
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/externalShakeInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[System.Serializable]
|
||||
public class externalShakeInfoListElement
|
||||
{
|
||||
public string name;
|
||||
public bool sameValueBothViews;
|
||||
public bool useDamageShakeInThirdPerson;
|
||||
public externalShakeInfo thirdPersonDamageShake;
|
||||
public bool useDamageShakeInFirstPerson;
|
||||
public externalShakeInfo firstPersonDamageShake;
|
||||
|
||||
public externalShakeInfoListElement (externalShakeInfoListElement newExternalShake)
|
||||
{
|
||||
name = newExternalShake.name;
|
||||
sameValueBothViews = newExternalShake.sameValueBothViews;
|
||||
useDamageShakeInThirdPerson = newExternalShake.useDamageShakeInThirdPerson;
|
||||
thirdPersonDamageShake = newExternalShake.thirdPersonDamageShake;
|
||||
useDamageShakeInFirstPerson = newExternalShake.useDamageShakeInFirstPerson;
|
||||
firstPersonDamageShake = newExternalShake.firstPersonDamageShake;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8eaa54e0a0210534a8eedd78c76b4bde
|
||||
timeCreated: 1514422143
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/externalShakeInfoListElement.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,83 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class externalShakeListManager : MonoBehaviour
|
||||
{
|
||||
public List<externalShakeInfoListElement> externalShakeInfoList = new List<externalShakeInfoListElement> ();
|
||||
|
||||
|
||||
|
||||
public const string mainManagerName = "External Shake List Manager";
|
||||
|
||||
public static string getMainManagerName ()
|
||||
{
|
||||
return mainManagerName;
|
||||
}
|
||||
|
||||
private static externalShakeListManager _externalShakeListManagerInstance;
|
||||
|
||||
public static externalShakeListManager Instance { get { return _externalShakeListManagerInstance; } }
|
||||
|
||||
bool instanceInitialized;
|
||||
|
||||
|
||||
public void getComponentInstance ()
|
||||
{
|
||||
if (instanceInitialized) {
|
||||
// print ("already initialized manager");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_externalShakeListManagerInstance != null && _externalShakeListManagerInstance != this) {
|
||||
Destroy (this.gameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_externalShakeListManagerInstance = this;
|
||||
|
||||
instanceInitialized = true;
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
getComponentInstance ();
|
||||
}
|
||||
|
||||
public void setShakeInManagerList (externalShakeInfoListElement element, int index)
|
||||
{
|
||||
externalShakeInfoList [index] = element;
|
||||
}
|
||||
|
||||
public void udpateAllHeadbobShakeList ()
|
||||
{
|
||||
headBob[] headBobList = FindObjectsOfType<headBob> ();
|
||||
foreach (headBob bob in headBobList) {
|
||||
bob.updateExternalShakeInfoList (externalShakeInfoList);
|
||||
}
|
||||
|
||||
print ("All head bob in the scene have been updated with the current shake list");
|
||||
}
|
||||
|
||||
public void setExternalShakeStateByIndex (int index, bool isFirstPerson)
|
||||
{
|
||||
externalShakeInfoListElement newShake = externalShakeInfoList [index];
|
||||
|
||||
headBob[] headBobList = FindObjectsOfType<headBob> ();
|
||||
|
||||
int headBobListLength = headBobList.Length;
|
||||
|
||||
for (int i = 0; i < headBobListLength; i++) {
|
||||
headBob bob = headBobList [i];
|
||||
|
||||
if (isFirstPerson) {
|
||||
bob.setExternalShakeState (newShake.firstPersonDamageShake);
|
||||
|
||||
} else {
|
||||
bob.setExternalShakeState (newShake.thirdPersonDamageShake);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0082f82322be03b4bad60878294b4c92
|
||||
timeCreated: 1514421539
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/externalShakeListManager.cs
|
||||
uploadId: 814740
|
||||
1053
Assets/Game Kit Controller/Scripts/Camera/Player Camera/headBob.cs
Normal file
1053
Assets/Game Kit Controller/Scripts/Camera/Player Camera/headBob.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39f970c91f016c04a87e392c873240f1
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/headBob.cs
|
||||
uploadId: 814740
|
||||
10066
Assets/Game Kit Controller/Scripts/Camera/Player Camera/playerCamera.cs
Normal file
10066
Assets/Game Kit Controller/Scripts/Camera/Player Camera/playerCamera.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d355886559d8f547bb1a1a0c0560b1c
|
||||
timeCreated: 1469551980
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/playerCamera.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,121 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class setCameraFOVValue : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cameraFOVChangeEnabled = true;
|
||||
|
||||
public float changeFOVAmount = 0.4f;
|
||||
|
||||
public Vector2 FOVClampValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool getMainPlayerCameraOnScene;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool mainCameraLocated;
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
|
||||
public void enableOrDisableCameraFOVChange (bool state)
|
||||
{
|
||||
cameraFOVChangeEnabled = state;
|
||||
}
|
||||
|
||||
public void increaseFov ()
|
||||
{
|
||||
if (!cameraFOVChangeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
changeFOV (1);
|
||||
}
|
||||
|
||||
public void decreaseFOV ()
|
||||
{
|
||||
if (!cameraFOVChangeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
changeFOV (-1);
|
||||
}
|
||||
|
||||
void changeFOV (float changeDirection)
|
||||
{
|
||||
checkMainCameraLocated ();
|
||||
|
||||
if (!mainCameraLocated) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainCamera.fieldOfView += (changeFOVAmount * changeDirection);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setting FOV value to " + mainCamera.fieldOfView);
|
||||
}
|
||||
|
||||
clampFOVValue ();
|
||||
}
|
||||
|
||||
public void setCameraFOV (float newValue)
|
||||
{
|
||||
checkMainCameraLocated ();
|
||||
|
||||
if (!mainCameraLocated) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainCamera.fieldOfView = newValue;
|
||||
|
||||
clampFOVValue ();
|
||||
}
|
||||
|
||||
void clampFOVValue ()
|
||||
{
|
||||
mainCamera.fieldOfView = Mathf.Clamp (mainCamera.fieldOfView, FOVClampValue.x, FOVClampValue.y);
|
||||
}
|
||||
|
||||
public void setFOVClampValueX (float newValue)
|
||||
{
|
||||
FOVClampValue.x = newValue;
|
||||
}
|
||||
|
||||
public void setFOVClampValueY (float newValue)
|
||||
{
|
||||
FOVClampValue.y = newValue;
|
||||
}
|
||||
|
||||
void checkMainCameraLocated ()
|
||||
{
|
||||
if (!mainCameraLocated) {
|
||||
mainCameraLocated = mainCamera != null;
|
||||
|
||||
if (!mainCameraLocated && getMainPlayerCameraOnScene) {
|
||||
playerCamera mainPlayerCamera = GKC_Utils.findMainPlayerCameraOnScene ();
|
||||
|
||||
if (mainPlayerCamera != null) {
|
||||
mainCamera = mainPlayerCamera.getMainCamera ();
|
||||
} else {
|
||||
mainCamera = Camera.main;
|
||||
}
|
||||
|
||||
mainCameraLocated = mainCamera != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 726d4c2371a49214cb814b25928188eb
|
||||
timeCreated: 1589092547
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Player Camera/setCameraFOVValue.cs
|
||||
uploadId: 814740
|
||||
9
Assets/Game Kit Controller/Scripts/Camera/Vehicles.meta
Normal file
9
Assets/Game Kit Controller/Scripts/Camera/Vehicles.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 281c970c908d13f4bbbe5b8b15ef6577
|
||||
folderAsset: yes
|
||||
timeCreated: 1504022649
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5055429832252e745aefbd9519945721
|
||||
timeCreated: 1458409320
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Vehicles/vehicleCameraController.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,206 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class vehicleCameraShake : MonoBehaviour
|
||||
{
|
||||
public List<bobStates> bobStatesList = new List<bobStates> ();
|
||||
public bool headBobEnabled;
|
||||
public bool shakingActive;
|
||||
public float ResetSpeed;
|
||||
public bobStates playerBobState;
|
||||
public bool externalShake;
|
||||
public string externalForceStateName;
|
||||
|
||||
bool mainCameraAssigned;
|
||||
|
||||
Transform mainCamera;
|
||||
Coroutine coroutineToStop;
|
||||
Coroutine externalForceCoroutine;
|
||||
float externalShakeDuration;
|
||||
|
||||
float eulTargetX;
|
||||
float eulTargetY;
|
||||
float eulTargetZ;
|
||||
Vector3 eulTarget;
|
||||
|
||||
bool vehicleActive;
|
||||
|
||||
string currentBobStateName = "";
|
||||
|
||||
float currentTimeTime;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
|
||||
//set a state in the current player state
|
||||
public void startShake (string shakeName)
|
||||
{
|
||||
if (!currentBobStateName.Equals (shakeName)) {
|
||||
//search the state recieved
|
||||
for (int i = 0; i < bobStatesList.Count; i++) {
|
||||
if (bobStatesList [i].Name.Equals (shakeName)) {
|
||||
//if found, set the state values, and the enable this state as the current state
|
||||
playerBobState = bobStatesList [i];
|
||||
bobStatesList [i].isCurrentState = true;
|
||||
|
||||
currentBobStateName = playerBobState.Name;
|
||||
//print ("New Shake State " + playerBobState.Name);
|
||||
} else {
|
||||
//disable all the other states
|
||||
bobStatesList [i].isCurrentState = false;
|
||||
}
|
||||
}
|
||||
|
||||
shakingActive = true;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
//if headbod enabled, check the current state
|
||||
if (mainCameraAssigned && headBobEnabled && shakingActive && playerBobState.stateEnabled) {
|
||||
movementBob (playerBobState);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopShake ()
|
||||
{
|
||||
shakingActive = false;
|
||||
|
||||
if (mainCameraAssigned) {
|
||||
if (coroutineToStop != null) {
|
||||
StopCoroutine (coroutineToStop);
|
||||
}
|
||||
|
||||
if (gameObject.activeInHierarchy) {
|
||||
coroutineToStop = StartCoroutine (resetCameraTransform ());
|
||||
}
|
||||
}
|
||||
|
||||
currentBobStateName = "";
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
//print ("stop shake");
|
||||
}
|
||||
|
||||
//check the info of the current state, to apply rotation, translation, both or anything according to the parameters of the botState
|
||||
void movementBob (bobStates state)
|
||||
{
|
||||
currentTimeTime = Time.time;
|
||||
|
||||
eulTargetX = Mathf.Sin (currentTimeTime * state.eulSpeed.x) * state.eulAmount.x;
|
||||
eulTargetY = Mathf.Cos (currentTimeTime * state.eulSpeed.y) * state.eulAmount.y;
|
||||
eulTargetZ = Mathf.Sin (currentTimeTime * state.eulSpeed.z) * state.eulAmount.z;
|
||||
|
||||
eulTarget = new Vector3 (eulTargetX, eulTargetY, eulTargetZ);
|
||||
|
||||
mainCamera.localRotation = Quaternion.Lerp (mainCamera.localRotation, Quaternion.Euler (eulTarget), Time.deltaTime * state.eulSmooth);
|
||||
}
|
||||
|
||||
IEnumerator resetCameraTransform ()
|
||||
{
|
||||
if (vehicleActive) {
|
||||
float i = 0.0f;
|
||||
float rate = ResetSpeed;
|
||||
|
||||
//store the current rotation
|
||||
Quaternion currentQ = mainCamera.localRotation;
|
||||
|
||||
Quaternion targetRotation = Quaternion.identity;
|
||||
|
||||
while (i < 1.0f) {
|
||||
//reset the position and rotation of the camera to 0,0,0
|
||||
i += Time.deltaTime * rate;
|
||||
|
||||
mainCamera.localRotation = Quaternion.Lerp (currentQ, targetRotation, i);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public void getCurrentCameraTransform (Transform currentCameraTransform)
|
||||
{
|
||||
mainCamera = currentCameraTransform;
|
||||
|
||||
mainCameraAssigned = mainCamera != null;
|
||||
}
|
||||
|
||||
public void setExternalShakeState (externalShakeInfo shakeInfo)
|
||||
{
|
||||
startShake (externalForceStateName);
|
||||
|
||||
playerBobState.eulAmount = shakeInfo.shakeRotation;
|
||||
playerBobState.eulSmooth = shakeInfo.shakeRotationSmooth;
|
||||
playerBobState.eulSpeed = shakeInfo.shakeRotationSpeed;
|
||||
externalShakeDuration = shakeInfo.shakeDuration;
|
||||
|
||||
setExternalShakeDuration ();
|
||||
}
|
||||
|
||||
public void setExternalShakeDuration ()
|
||||
{
|
||||
externalShake = true;
|
||||
|
||||
if (externalForceCoroutine != null) {
|
||||
StopCoroutine (externalForceCoroutine);
|
||||
}
|
||||
|
||||
externalForceCoroutine = StartCoroutine (setExternalShakeDurationCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator setExternalShakeDurationCoroutine ()
|
||||
{
|
||||
WaitForSeconds delay = new WaitForSeconds (externalShakeDuration);
|
||||
|
||||
yield return delay;
|
||||
|
||||
externalShake = false;
|
||||
|
||||
stopShake ();
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public void setVehicleActiveState (bool state)
|
||||
{
|
||||
vehicleActive = state;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class bobStates
|
||||
{
|
||||
public string Name;
|
||||
public Vector3 eulAmount;
|
||||
public Vector3 eulSpeed;
|
||||
public float eulSmooth;
|
||||
public bool stateEnabled;
|
||||
public bool isCurrentState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5a1e781b9bc0fb48bdbc84ef81a2a05
|
||||
timeCreated: 1470416541
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Camera/Vehicles/vehicleCameraShake.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user