You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
769 B
C#
32 lines
769 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Grass : MonoBehaviour {
|
|
public bool isEaten;
|
|
public Mesh uneatenMesh;
|
|
public Mesh eatenMesh;
|
|
|
|
private MeshFilter meshFilter;
|
|
|
|
// Start is called before the first frame update
|
|
void Start() {
|
|
meshFilter = GetComponent<MeshFilter>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update() {
|
|
if (isEaten) {
|
|
meshFilter.mesh = eatenMesh;
|
|
} else {
|
|
meshFilter.mesh = uneatenMesh;
|
|
}
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D collider) {
|
|
if (collider.CompareTag("Player") || collider.CompareTag("Enemy")) {
|
|
isEaten = true;
|
|
}
|
|
}
|
|
}
|