Domyno/Assets/Scripts/PlacerObject.cs
Gerard Gascón 27755409e3 init
2025-04-24 17:33:35 +02:00

31 lines
746 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlacerObject : MonoBehaviour{
bool canPlace = true;
public bool CanPlace { get { return canPlace; } }
[SerializeField] Color canPlaceColor, cannotPlaceColor;
Material material;
void Start(){
material = GetComponent<MeshRenderer>().material;
}
void OnTriggerStay(Collider other){
if (other.CompareTag("Piece") || other.CompareTag("Button") || other.CompareTag("Obstacle")){
canPlace = false;
material.color = cannotPlaceColor;
}
}
void OnTriggerExit(Collider other){
if (other.CompareTag("Piece") || other.CompareTag("Button") || other.CompareTag("Obstacle")){
canPlace = true;
material.color = canPlaceColor;
}
}
}