-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLadder.cs
More file actions
executable file
·34 lines (28 loc) · 825 Bytes
/
Ladder.cs
File metadata and controls
executable file
·34 lines (28 loc) · 825 Bytes
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
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (BoxCollider))]
public class Ladder : MonoBehaviour {
public static int playerTriggerBelonging = 0;
void Start () {
gameObject.GetComponentInChildren<BoxCollider>().isTrigger = true;
}
// void OnTriggerStay(Collider other){
// if(other.CompareTag("Player") && Input.GetAxis("Vertical") > 0.1f){
// other.transform.Translate(Vector3.up * Input.GetAxis("Vertical"));
// }
//
// }
void OnTriggerEnter(Collider other){
if(other.CompareTag("Player")){
playerTriggerBelonging++;
other.GetComponent<BaseCharacter>().Climb(true);
}
}
void OnTriggerExit(Collider other){
if(other.CompareTag("Player")){
playerTriggerBelonging--;
if(playerTriggerBelonging == 0)
other.GetComponent<BaseCharacter>().Climb(false);
}
}
}