-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLaserPointCorrection.cs
More file actions
49 lines (40 loc) · 1.52 KB
/
LaserPointCorrection.cs
File metadata and controls
49 lines (40 loc) · 1.52 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GHPC.Equipment.Optics;
using UnityEngine;
namespace PactIncreasedLethality
{
internal class LaserPointCorrection : MonoBehaviour
{
public Transform laser;
public Vector3 preserved_spot_day;
public Quaternion preserved_rotation_day;
public Vector3 preserved_spot_night;
public Quaternion preserved_rotation_night;
public UsableOptic day_optic;
public UsableOptic night_optic;
void Start() {
laser.SetParent(day_optic.transform, true);
preserved_spot_day = laser.transform.localPosition;
preserved_rotation_day = laser.transform.localRotation;
laser.SetParent(night_optic.transform, true);
preserved_spot_night = laser.transform.localPosition;
preserved_rotation_night = laser.transform.localRotation;
laser.SetParent(day_optic.transform, true);
}
void Update() {
if (day_optic.isActiveAndEnabled)
{
laser.SetParent(day_optic.transform, true);
laser.transform.SetLocalPositionAndRotation(preserved_spot_day, preserved_rotation_day);
}
if (night_optic.isActiveAndEnabled) {
laser.SetParent(night_optic.transform, true);
laser.transform.SetLocalPositionAndRotation(preserved_spot_night, preserved_rotation_night);
}
}
}
}