Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / WorldLimiter.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WorldLimiter : MonoBehaviour
{
    private PlayerController playerController;
    private PostProcessingController postProcessingController;
    void Start()
    {
        playerController = GetComponent<PlayerController>();
        postProcessingController = Camera.main.GetComponent<PostProcessingController>();
        playerController.transpassedCoordinate = new Vector3(0, 1000, 0);
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log(playerController.transpassedCoordinate);
        
        if (playerController.transpassedCoordinate != new Vector3(0,1000,0))
        {
            if(Vector3.Distance(transform.position, playerController.transpassedCoordinate) > 10)
            {
                Debug.Log("Fuck!");
                transform.position += (playerController.transpassedCoordinate - transform.position) * 1.1f;
                EndPostProcessing();
            }
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Barrier"))
        {

            Debug.Log(playerController.transpassedCoordinate);
            if (playerController.transpassedCoordinate == new Vector3(0, 1000, 0))
            {
                Debug.Log("Changing PostProcessing");
                playerController.transpassedCoordinate = transform.position;
            }
            else
            {
                EndPostProcessing();
            }
        }
    }
    private void EndPostProcessing()
    {
        postProcessingController.UpdatePostProcessing(0);
        playerController.transpassedCoordinate = new Vector3(0,1000,0);
    }
}