2019-11-22 17:38:28 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace cylvester
|
|
|
|
|
{
|
|
|
|
|
interface IPitchPosition
|
|
|
|
|
{
|
|
|
|
|
float Position { set; }
|
|
|
|
|
}
|
|
|
|
|
public class PitchPosition : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] float pitchMultiplier = 0.1f;
|
2020-01-23 19:35:09 +00:00
|
|
|
|
[SerializeField] float yOffset = 0;
|
|
|
|
|
[SerializeField] float xOffset = 0;
|
|
|
|
|
[SerializeField] float zOffset = 0;
|
2019-11-22 17:38:28 +00:00
|
|
|
|
private Vector3 originalPosition;
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
originalPosition = GetComponent<Transform>().position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Position
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
var pitchOffset = value * pitchMultiplier;
|
2020-01-23 19:35:09 +00:00
|
|
|
|
transform.localPosition = new Vector3(originalPosition.x + (pitchOffset * xOffset),
|
|
|
|
|
originalPosition.y + (pitchOffset * yOffset),
|
|
|
|
|
originalPosition.z + (pitchOffset + zOffset));
|
2019-11-22 17:38:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|