Skip to content
Snippets Groups Projects
Commit f220fcb4 authored by Matthewit Dechatech's avatar Matthewit Dechatech
Browse files

Quick cleanup

parent 166bb91a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -27,7 +27,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 175064}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 63.9300003, y: -.419999987, z: -15}
m_LocalPosition: {x: 0, y: 0, z: -15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Loading
Loading
@@ -136,6 +136,14 @@ Prefab:
propertyPath: SnapOnInit
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 175064}
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 144678}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 63.9300003, y: -.419999987, z: -15}
m_LocalPosition: {x: 0, y: 0, z: -15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Loading
Loading
@@ -128,6 +128,14 @@ Prefab:
propertyPath: SnapOnInit
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 144678}
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 198666}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 63.9300003, y: -.419999987, z: -15}
m_LocalPosition: {x: 0, y: 0, z: -15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Loading
Loading
@@ -132,6 +132,14 @@ Prefab:
propertyPath: SpindashLag
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 198666}
Loading
Loading
Loading
Loading
@@ -285,6 +285,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 03a559950131d2045bf2c80c2cf6408a, type: 3}
m_Name:
m_EditorClassIdentifier:
PlatformTrigger: {fileID: 0}
CollidingTrigger:
CollidingBool:
SurfaceTrigger:
SurfaceBool:
ActivateDelay: .533333302
BrokenTrigger: Broken
--- !u!114 &11494046
Loading
Loading
Loading
Loading
@@ -149,7 +149,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 157062}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 64.0712509, y: -.981733322, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 450792}
Loading
Loading
Loading
Loading
@@ -59,7 +59,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 124706}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 64.887001, y: -.229000002, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 457578}
Loading
Loading
@@ -268,7 +268,15 @@ Prefab:
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_Modifications:
- target: {fileID: 0}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 124706}
Loading
Loading
using UnityEngine;
namespace Hedgehog.Core.Actors
{
/// <summary>
/// Speeds up an animation based on an animator float. Great for making walk cycles faster
/// when a controller picks up speed.
/// </summary>
public class CycleSpeedup : StateMachineBehaviour
{
/// <summary>
/// Name of an Animator float to change animation speed with.
/// </summary>
[SerializeField]
[Tooltip("Name of an Animator float to change animation speed with.")]
public string SpeedParameter;
/// <summary>
/// Whether to use the parameter's absolute value.
/// </summary>
[SerializeField]
[Tooltip("Whether to use the parameter's absolute value.")]
public bool UseAbsoluteValue;
/// <summary>
/// Animator speed vs speed parameter.
/// </summary>
[SerializeField]
[Tooltip("Animator speed vs speed parameter.")]
public AnimationCurve AnimationSpeedCurve;
private float _originalSpeed;
public void Reset()
{
SpeedParameter = "";
UseAbsoluteValue = true;
AnimationSpeedCurve = AnimationCurve.Linear(0.0f, 1.0f, 3.15f, 4.0f);
}
public void Awake()
{
_originalSpeed = 1.0f;
}
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
_originalSpeed = animator.speed;
}
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.speed =
Mathf.Max(0.0f,
UseAbsoluteValue
? Mathf.Abs(AnimationSpeedCurve.Evaluate(animator.GetFloat(SpeedParameter)))
: AnimationSpeedCurve.Evaluate(animator.GetFloat(SpeedParameter)));
}
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.speed = _originalSpeed;
}
}
}
fileFormatVersion: 2
guid: bb1fadafcb0106f46ae92ab5ba69d790
timeCreated: 1446114545
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading
Loading
@@ -197,6 +197,7 @@ public void Awake()
 
public void Start()
{
// Try and find a target if one isn't specified
if (Target == null)
{
Target = FindObjectOfType<HedgehogController>();
Loading
Loading
@@ -235,6 +236,7 @@ public void LateUpdate()
/// <param name="previousTarget">The camera's previous target. Nullable.</param>
public void OnChangeTarget(HedgehogController previousTarget)
{
// Add listeners for look up and duck
Target.MoveManager.OnPerform.AddListener(OnPerformMove);
Target.MoveManager.OnEnd.AddListener(OnEndMove);
 
Loading
Loading
@@ -243,10 +245,12 @@ public void OnChangeTarget(HedgehogController previousTarget)
_previousTargetPosition = Target.transform.position;
_previousTarget = Target;
 
// Cache moves for speed
LookUp = Target.GetMove<LookUp>();
Duck = Target.GetMove<Duck>();
Spindash = Target.GetMove<Spindash>();
 
// Clean up listeners from the last target
if (previousTarget == null)
return;
previousTarget.MoveManager.OnPerform.RemoveListener(OnPerformMove);
Loading
Loading
@@ -273,7 +277,8 @@ protected void HandleState()
 
if (CurrentState == State.Follow)
{
if (LookUp.Active)
// State change for looking up
if (LookUp != null && LookUp.Active)
{
CurrentState = State.LookUp;
LagTimer = LookUpLag;
Loading
Loading
@@ -281,7 +286,8 @@ protected void HandleState()
return;
}
 
if (Duck.Active && !Spindash.Active)
// State change for ducking (and not spindashing)
if (Duck != null && Duck.Active && (Spindash == null || !Spindash.Active))
{
CurrentState = State.LookDown;
LagTimer = LookDownLag;
Loading
Loading
@@ -289,6 +295,7 @@ protected void HandleState()
return;
}
 
// State change for Sonic CD forward shift, check horizontal speed
if (DoForwardShift && Target.RelativeVelocity.x > ForwardShiftMinSpeed)
{
CurrentState = State.ForwardShift;
Loading
Loading
@@ -296,10 +303,14 @@ protected void HandleState()
return;
}
 
// Get the controller's distance from the camera
var offset = (Vector2)(t.position - (transform.position + (Vector3)FollowCenter));
var followSpeed = FollowSpeed * Time.deltaTime;
// Get maximum camera movement
var followSpeed = FollowSpeed*Time.deltaTime;
float changeX = 0.0f, changeY = 0.0f;
 
// If controller distance is greater than follow radius, set changes in position
if (offset.x < -FollowRadius.x)
{
changeX = offset.x + FollowRadius.x;
Loading
Loading
@@ -318,12 +329,16 @@ protected void HandleState()
changeY = offset.y - FollowRadius.y;
}
 
// Limit position change to follow speed
var change = new Vector3(Mathf.Clamp(changeX, -followSpeed, followSpeed),
Mathf.Clamp(changeY, -followSpeed, followSpeed));
// Apply position change
transform.position += change;
}
else if (CurrentState == State.Lag)
{
// Decrease lag timer, back to normal if it's zero
LagTimer -= Time.deltaTime;
if (LagTimer < 0.0f)
{
Loading
Loading
@@ -333,7 +348,7 @@ protected void HandleState()
}
else if (CurrentState == State.LookUp)
{
//
// Lag before beginning camera movement
LagTimer -= Time.deltaTime;
if (LagTimer < 0.0f)
LagTimer = 0.0f;
Loading
Loading
@@ -343,7 +358,10 @@ protected void HandleState()
Vector2 change;
if (LookReturning)
{
// Keep track of how much the camera's gone back
LookAmount -= LookUpPanSpeed * Time.deltaTime;
// If look amount is zero, we're back to normal
if (LookAmount < 0.0f)
{
LookAmount = 0.0f;
Loading
Loading
@@ -352,40 +370,48 @@ protected void HandleState()
return;
}
 
change = -DMath.AngleToVector((Target.GravityDirection + 180.0f) * Mathf.Deg2Rad) * LookUpPanSpeed *
// Return to original position by moving in the opposite direction
change = -DMath.AngleToVector((Target.GravityDirection + 180.0f)*Mathf.Deg2Rad)*LookUpPanSpeed*
Time.deltaTime;
}
else
{
LookAmount += LookUpPanSpeed * Time.deltaTime;
// Keep track of how far the camera's gone
LookAmount += LookUpPanSpeed*Time.deltaTime;
if (LookAmount > LookUpPanAmount)
{
LookAmount = LookUpPanAmount;
return;
}
 
change = DMath.AngleToVector((Target.GravityDirection + 180.0f) * Mathf.Deg2Rad) * LookUpPanSpeed *
// Translate based on gravity, pan speed, and change in time
change = DMath.AngleToVector((Target.GravityDirection + 180.0f)*Mathf.Deg2Rad)*LookUpPanSpeed*
Time.deltaTime;
}
 
// Apply translation
To((Vector2)transform.position + change);
}
else if (CurrentState == State.LookDown)
{
// Lag before beginning camera movement
LagTimer -= Time.deltaTime;
if (LagTimer < 0.0f)
LagTimer = 0.0f;
else
return;
 
// Back to normal if a spindash starts
if (Spindash.Active)
{
LookReturning = true;
}
 
// If look amount is zero, we're back to normal
Vector2 change;
if (LookReturning)
{
// Keep track of how much the camera's gone back
LookAmount -= LookDownPanSpeed * Time.deltaTime;
if (LookAmount < 0.0f)
{
Loading
Loading
@@ -395,11 +421,13 @@ protected void HandleState()
return;
}
 
// Return to original position by moving in the opposite direction
change = -DMath.AngleToVector(Target.GravityDirection * Mathf.Deg2Rad) * LookDownPanSpeed *
Time.deltaTime;
}
else
{
// Keep track of how far the camera's gone
LookAmount += LookDownPanSpeed * Time.deltaTime;
if (LookAmount > LookDownPanAmount)
{
Loading
Loading
@@ -407,16 +435,21 @@ protected void HandleState()
return;
}
 
// Translate based on gravity, pan speed, and change in time
change = DMath.AngleToVector(Target.GravityDirection * Mathf.Deg2Rad) * LookDownPanSpeed *
Time.deltaTime;
}
 
// Apply translation
To((Vector2)transform.position + change);
}
else if (CurrentState == State.ForwardShift)
{
// Apply change in position from the last update, necessary here since the camera is panning
// forward and following the target simulataneously
To((Vector2)transform.position + ((Vector2)t.position - _previousTargetPosition));
 
// Pan back if target doesn't meet the conditions anymore
if (Target.RelativeVelocity.x < ForwardShiftMinSpeed || !DoForwardShift)
{
LookReturning = true;
Loading
Loading
@@ -425,7 +458,10 @@ protected void HandleState()
Vector2 change;
if (LookReturning)
{
// Keep track of how much the camera's gone back
LookAmount -= ForwardShiftPanSpeed*Time.deltaTime;
// If look amount is zero, we're back to normal
if (LookAmount < 0.0f)
{
LookAmount = 0.0f;
Loading
Loading
@@ -434,11 +470,13 @@ protected void HandleState()
return;
}
 
// Return to original position by moving in the opposite direction
change = -DMath.AngleToVector((Target.GravityDirection + 90.0f)*Mathf.Deg2Rad)*ForwardShiftPanSpeed*
Time.deltaTime;
}
else
{
// Keep track of how far the camera's gone
LookAmount += ForwardShiftPanSpeed * Time.deltaTime;
if (LookAmount > ForwardShiftPanAmount)
{
Loading
Loading
@@ -446,24 +484,37 @@ protected void HandleState()
return;
}
 
// Translate based on gravity, pan speed, and change in time
change = DMath.AngleToVector((Target.GravityDirection + 90.0f)*Mathf.Deg2Rad)*ForwardShiftPanSpeed*
Time.deltaTime;
}
 
// Apply translation
To((Vector2)transform.position + change);
}
}
 
/// <summary>
/// Sets only the x and y components of the camera's position to the specified position.
/// </summary>
/// <param name="position">The specified position.</param>
public void To(Vector2 position)
{
transform.position = new Vector3(position.x, position.y, transform.position.z);
}
 
/// <summary>
/// Rotates the camera about the z-axis to the specified orientation.
/// </summary>
/// <param name="degrees">The specified orientation, in degrees.</param>
public void Rotate(float degrees)
{
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, degrees);
}
 
/// <summary>
/// Begins the spindash lag timer.
/// </summary>
public void DoSpindashLag()
{
LagTimer = SpindashLag;
Loading
Loading
Loading
Loading
@@ -113,8 +113,11 @@ public override void OnPlatformEnter(TerrainCastHit hit)
if (hit.Controller.Animator != null)
{
var logWarnings = hit.Controller.Animator.logWarnings;
hit.Controller.Animator.logWarnings = false;
if (!string.IsNullOrEmpty(HitTrigger))
hit.Controller.Animator.SetTrigger(HitTrigger);
hit.Controller.Animator.logWarnings = logWarnings;
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment