-
Notifications
You must be signed in to change notification settings - Fork 0
/
AttachTarget.cs
89 lines (68 loc) · 3.8 KB
/
AttachTarget.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using UnityEngine;
using Photon.Pun;
/// <summary>
/// 同期させたいアバターのルートにアタッチ
/// </summary>
public class AttachTarget : MonoBehaviourPunCallbacks
{
bool once = true;
[SerializeField]
GameObject avater_Face, avater_RightHand, avater_LeftHand, avater_RightFoot, avater_LeftFoot;
Transform cameraTransform;
Transform rightHandTransform;
Transform leftHandTransform;
Transform rightFootTransform;
Transform leftFootTransform;
void Update()
{
if (photonView.IsMine && once)
{
cameraTransform = GameObject.Find("HeadTarget1").GetComponent<Transform>();
rightHandTransform = GameObject.Find("RightHandTarget1").GetComponent<Transform>();
leftHandTransform = GameObject.Find("LeftHandTarget1").GetComponent<Transform>();
rightFootTransform = GameObject.Find("RightFootTarget1").GetComponent<Transform>();
leftFootTransform = GameObject.Find("LeftFootTarget1").GetComponent<Transform>();
//親子関係を設定し、ローカルの座標系の原点に移動
avater_Face.transform.parent = cameraTransform;
avater_RightHand.transform.parent = rightHandTransform;
avater_LeftHand.transform.parent = leftHandTransform;
avater_RightFoot.transform.parent = rightFootTransform;
avater_LeftFoot.transform.parent = leftFootTransform;
avater_Face.transform.localPosition = Vector3.zero;
avater_Face.transform.localRotation = Quaternion.identity;
avater_RightHand.transform.localPosition = Vector3.zero;
avater_RightHand.transform.localRotation = Quaternion.identity;
avater_LeftHand.transform.localPosition = Vector3.zero;
avater_LeftHand.transform.localRotation = Quaternion.identity;
avater_RightFoot.transform.localPosition = Vector3.zero;
avater_RightFoot.transform.localRotation = Quaternion.identity;
avater_LeftFoot.transform.localPosition = Vector3.zero;
avater_LeftFoot.transform.localRotation = Quaternion.identity;
once = false;
}
if (!photonView.IsMine && once)
{
cameraTransform = GameObject.Find("HeadTarget2").GetComponent<Transform>();
rightHandTransform = GameObject.Find("RightHandTarget2").GetComponent<Transform>();
leftHandTransform = GameObject.Find("LeftHandTarget2").GetComponent<Transform>();
rightFootTransform = GameObject.Find("RightFootTarget2").GetComponent<Transform>();
leftFootTransform = GameObject.Find("LeftFootTarget2").GetComponent<Transform>();
//親子関係を設定し、ローカルの座標系の原点に移動
avater_Face.transform.parent = cameraTransform;
avater_RightHand.transform.parent = rightHandTransform;
avater_LeftHand.transform.parent = leftHandTransform;
avater_RightFoot.transform.parent = rightFootTransform;
avater_LeftFoot.transform.parent = leftFootTransform;
avater_Face.transform.localPosition = Vector3.zero;
avater_Face.transform.localRotation = Quaternion.identity;
avater_RightHand.transform.localPosition = Vector3.zero;
avater_RightHand.transform.localRotation = Quaternion.identity;
avater_LeftHand.transform.localPosition = Vector3.zero;
avater_LeftHand.transform.localRotation = Quaternion.identity;
avater_RightFoot.transform.localPosition = Vector3.zero;
avater_RightFoot.transform.localRotation = Quaternion.identity;
avater_LeftFoot.transform.localPosition = Vector3.zero;
avater_LeftFoot.transform.localRotation = Quaternion.identity;
}
}
}