summaryrefslogtreecommitdiff
path: root/Other/NavMeshTest/Assets/Scripts/MovingPlatform.cs
blob: 6907636e8304f9937a58dbe3b8280c9ed1e864fd (plain)
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MovingPlatform : MonoBehaviour
{

    private void OnTriggerEnter(Collider other)
    {

        Debug.Log("trigger");

        if(other.gameObject.CompareTag("Player"))
        {
            other.gameObject.transform.SetParent(transform);
        }
        
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            other.gameObject.transform.SetParent(null);
        }
    }

}