-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOurPlayerController.cs
More file actions
68 lines (46 loc) · 1.74 KB
/
OurPlayerController.cs
File metadata and controls
68 lines (46 loc) · 1.74 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
// This script allows the users to control the Player Game Object
// This script is using the UnityEngine.Networking class
public class OurPlayerController : NetworkBehaviour
{
// Declare the three bridge game objects
public GameObject BridgeHead;
public GameObject BridgeRightHand;
public GameObject BridgeLeftHand;
// Declare the three steamvr game objects
public GameObject SteamVRHead;
public GameObject SteamVRRightHand;
public GameObject SteamVRLeftHand;
public GameObject StreamVrObject;
[SyncVar]
public GameObject seed;
public Transform seedLocation;
// In start define the steamvr objects by finding their scripts
void Start()
{
if (isLocalPlayer)
{
gameObject.name = "LocalPlayer";
}
else
{
StreamVrObject.SetActive(false);
gameObject.name = "NetworkedPlayer";
}
}
// In update, each bridge object = corresponding steamvr object's position & again for the rotation
void Update()
{
if (!isLocalPlayer)
return;
BridgeHead.transform.position = SteamVRHead.transform.position;
BridgeRightHand.transform.position = SteamVRRightHand.transform.position;
BridgeLeftHand.transform.position = SteamVRLeftHand.transform.position;
BridgeHead.transform.rotation = SteamVRHead.transform.rotation;
BridgeRightHand.transform.rotation = SteamVRRightHand.transform.rotation;
BridgeLeftHand.transform.rotation = SteamVRLeftHand.transform.rotation;
}
}