-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadjustPos.cs
31 lines (28 loc) · 852 Bytes
/
adjustPos.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class adjustPos : MonoBehaviour
{
public Vector3 ratio;
public Vector3 defaultRotation;
public Transform sourceObject;
public Transform targetObject;
//public bikeValStore valueDict;
// Start is called before the first frame update
void Start()
{
//parentTransform = transform.parent;
defaultRotation = targetObject.transform.localEulerAngles;
}
// Update is called once per frame
public void Step()
{
float localAngle = sourceObject.localEulerAngles.y;
if (localAngle > 180)
{
localAngle -= 360;
}
//valueDict.Save("rot", localAngle);
targetObject.transform.localRotation = Quaternion.Euler(defaultRotation + ratio * localAngle);
}
}