移除ECM2
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ECM2.Walkthrough.Ex71
|
||||
{
|
||||
/// <summary>
|
||||
/// This example shows how to implement a moving platform.
|
||||
/// It will loop from its start position (ie: transform.position) to its target position
|
||||
/// (ie: startPosition + offset) during moveTime seconds.
|
||||
/// </summary>
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class KinematicMove : MonoBehaviour
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
[SerializeField]
|
||||
public float _moveTime = 3.0f;
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 _offset;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PRIVATE FIELDS
|
||||
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
private Vector3 _startPosition;
|
||||
private Vector3 _targetPosition;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public float moveTime
|
||||
{
|
||||
get => _moveTime;
|
||||
set => _moveTime = Mathf.Max(0.0001f, value);
|
||||
}
|
||||
|
||||
public Vector3 offset
|
||||
{
|
||||
get => _offset;
|
||||
set => _offset = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region METHODS
|
||||
|
||||
/// <summary>
|
||||
/// Sinusoidal ease function.
|
||||
/// </summary>
|
||||
|
||||
public static float EaseInOut(float time, float duration)
|
||||
{
|
||||
return -0.5f * (Mathf.Cos(Mathf.PI * time / duration) - 1.0f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MONOBEHAVIOUR
|
||||
|
||||
public void OnValidate()
|
||||
{
|
||||
moveTime = _moveTime;
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
_rigidbody.isKinematic = true;
|
||||
|
||||
_startPosition = transform.position;
|
||||
_targetPosition = _startPosition + offset;
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
{
|
||||
float t = EaseInOut(Mathf.PingPong(Time.time, _moveTime), _moveTime);
|
||||
Vector3 p = Vector3.Lerp(_startPosition, _targetPosition, t);
|
||||
|
||||
_rigidbody.MovePosition(p);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2d405b3de076484b8e730438877207d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,70 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ECM2.Walkthrough.Ex71
|
||||
{
|
||||
/// <summary>
|
||||
/// This example shows how to implement a rotating platform.
|
||||
/// This will freely rotate at the given rotation speed along its defined rotationAxis.
|
||||
/// </summary>
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class KinematicRotate : MonoBehaviour
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
[SerializeField]
|
||||
private float _rotationSpeed = 30.0f;
|
||||
|
||||
public Vector3 rotationAxis = Vector3.up;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PRIVATE FIELDS
|
||||
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
private float _angle;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public float rotationSpeed
|
||||
{
|
||||
get => _rotationSpeed;
|
||||
set => _rotationSpeed = value;
|
||||
}
|
||||
|
||||
public float angle
|
||||
{
|
||||
get => _angle;
|
||||
set => _angle = MathLib.ClampAngle(value, 0.0f, 360.0f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MONOBEHAVIOUR
|
||||
|
||||
public void OnValidate()
|
||||
{
|
||||
rotationSpeed = _rotationSpeed;
|
||||
rotationAxis = rotationAxis.normalized;
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
_rigidbody.isKinematic = true;
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
{
|
||||
angle += rotationSpeed * Time.deltaTime;
|
||||
|
||||
Quaternion rotation = Quaternion.AngleAxis(rotationSpeed * Time.deltaTime, rotationAxis.normalized);
|
||||
_rigidbody.MoveRotation(_rigidbody.rotation * rotation);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eee584f3f511f07478029e018c96d42f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user