49 lines
851 B
C#
49 lines
851 B
C#
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
public class MegaHoseAttach : MonoBehaviour
|
|
{
|
|
public float alpha;
|
|
|
|
public MegaHose hose;
|
|
|
|
public Vector3 offset = Vector3.zero;
|
|
|
|
public Vector3 rotate = Vector3.zero;
|
|
|
|
public bool doLateUpdate = true;
|
|
|
|
public bool rot = true;
|
|
|
|
private void Update()
|
|
{
|
|
if (!doLateUpdate)
|
|
{
|
|
PositionObject();
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (doLateUpdate)
|
|
{
|
|
PositionObject();
|
|
}
|
|
}
|
|
|
|
private void PositionObject()
|
|
{
|
|
if ((bool)hose)
|
|
{
|
|
Vector3 position = hose.GetPosition(alpha);
|
|
if (rot)
|
|
{
|
|
Vector3 position2 = hose.GetPosition(alpha + 0.001f);
|
|
Quaternion rotation = Quaternion.LookRotation(position2 - position) * Quaternion.Euler(rotate);
|
|
base.transform.rotation = rotation;
|
|
}
|
|
base.transform.position = position + base.transform.TransformDirection(offset);
|
|
}
|
|
}
|
|
}
|