-
Notifications
You must be signed in to change notification settings - Fork 1
/
WaterMultiplayer.cs
56 lines (50 loc) · 1.92 KB
/
WaterMultiplayer.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class WaterMultiplayer : MonoBehaviour
{
private PhotonView photonView;
// Running and rowing movement scripts
private RunningMovementMultiplayer runningMovement;
private RowingMovementMultiplayer rowingMovement;
// Start is called before the first frame update
void Start()
{
photonView = GetComponent<PhotonView>();
if (photonView.IsMine)
{
// Get components for running and rowing movement scripts
runningMovement = GetComponent<RunningMovementMultiplayer>();
rowingMovement = GetComponent<RowingMovementMultiplayer>();
}
}
// OnTriggerEnter is called when a GameObject collides with another GameObject.
private void OnTriggerEnter(Collider other)
{
if (photonView.IsMine && GameManager.gameStage == GameStage.Playing)
{
// Executes if this collider touches an object with the "water" tag
if (other.gameObject.CompareTag("Water"))
{
// GameObject.FindGameObjectWithTag("Water").GetComponent<Renderer>().material.color = Color.green;
runningMovement.enabled = false;
rowingMovement.enabled = true;
}
}
}
// OnTriggerExit is called when the Collider has stopped touching the trigger.
private void OnTriggerExit(Collider other)
{
if (photonView.IsMine && GameManager.gameStage == GameStage.Playing)
{
// Executes if this collider touches an object with the "water" tag
if (other.gameObject.CompareTag("Water"))
{
// GameObject.FindGameObjectWithTag("Water").GetComponent<Renderer>().material.color = Color.red;
runningMovement.enabled = true;
rowingMovement.enabled = false;
}
}
}
}