SpawnPosition
How do I use Spawn Position
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
19 | if (this.SpawnPosition != null) | 1 |
File name: OnJoinedInstantiate.cs
Copy
10 public void OnJoinedRoom()
11 {
12 if (this.PrefabsToInstantiate != null)
13 {
14 foreach (GameObject o in this.PrefabsToInstantiate)
15 {
16 Debug.Log("Instantiating: " + o.name);
17
18 Vector3 spawnPos = Vector3.up;
19 if (this.SpawnPosition != null)
20 {
21 spawnPos = this.SpawnPosition.position;
22 }
23
24 Vector3 random = Random.insideUnitSphere;
25 random.y = 0;
26 random = random.normalized;
27 Vector3 itempos = spawnPos + this.PositionOffset * random;
28
29 PhotonNetwork.Instantiate(o.name, itempos, Quaternion.identity, 0);
30 }
31 }
32 }
SpawnPosition 115 lượt xem
Gõ tìm kiếm nhanh...