rabidus-test/Assets/Amazing Assets/Curved World/Example Scenes/Files/Scripts/TransformStaticPosition.cs

37 lines
984 B
C#
Raw Normal View History

2023-10-02 19:12:35 +03:00
using UnityEngine;
namespace AmazingAssets.CurvedWorld.Example
{
public class TransformStaticPosition : MonoBehaviour
{
public CurvedWorld.CurvedWorldController curvedWorldController;
Vector3 originalPosition;
Quaternion originalRotation;
Vector3 forward;
Vector3 right;
private void Start()
{
originalPosition = transform.position;
originalRotation = transform.rotation;
forward = transform.forward;
right = transform.right;
}
void Update()
{
if (curvedWorldController != null)
{
//Transform position
transform.position = curvedWorldController.TransformPosition(originalPosition);
//Transform normal (calcualte rotation)
transform.rotation = curvedWorldController.TransformRotation(originalPosition, forward, right);
}
}
}
}