質問編集履歴
2
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,6 +42,68 @@
|
|
42
42
|
|
43
43
|
|
44
44
|
|
45
|
+
プレイヤーをテレポートさせる際に、プレイヤーの侵入を検知し、座標を変えるスクリプト
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
このスクリプトは、Is Triggerをオンにした球形のコライダーを作り、そこにアタッチしたものです。
|
50
|
+
|
51
|
+
また、テレポート先にTptoという名のオブジェクトがあり、プレイヤーの侵入を検知した際に、そのオブジェクトにプレイヤーの座標を設定するという仕組みになっています。
|
52
|
+
|
53
|
+
```C#
|
54
|
+
|
55
|
+
using System.Collections;
|
56
|
+
|
57
|
+
using System.Collections.Generic;
|
58
|
+
|
59
|
+
using UnityEngine;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
public class into1 : MonoBehaviour {
|
64
|
+
|
65
|
+
public GameObject Player;
|
66
|
+
|
67
|
+
public GameObject Tpto;
|
68
|
+
|
69
|
+
// Start is called before the first frame update
|
70
|
+
|
71
|
+
void Start () {
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
// Update is called once per frame
|
80
|
+
|
81
|
+
void Update () {
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
void OnTriggerEnter (Collider col1) {
|
88
|
+
|
89
|
+
if (col1.CompareTag ("Player")) {
|
90
|
+
|
91
|
+
Player.transform.position = Tpto.transform.position;
|
92
|
+
|
93
|
+
Debug.Log ("true");
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
45
107
|
### 試したこと
|
46
108
|
|
47
109
|
・Playerの中のBodyなどの一部のオブジェクトにRigidbodyとスクリプトを移動させたがそもそも移動できなくなった。
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,6 +32,8 @@
|
|
32
32
|
|
33
33
|
結論としては、RigidBodyとColliderが別々のオブジェクトにアタッチされていたのが原因でした。
|
34
34
|
|
35
|
+
※PlayerにRigidBodyが付いていて、Prim.00000000にMeshColliderが付いていてしまっているということです。
|
36
|
+
|
35
37
|
|
36
38
|
|
37
39
|
RigidBodyとColliderを同じオブジェクトにアタッチしたいのですが、自分の力ではどうしてもすることが出来ませんでした。
|