I have a game where you eat pellets and then you grow, but when you grow, it slowly becomes a slab when you eat. code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class testTrigger : MonoBehaviour
{
public Vector3 size;
public Collider objDisappear;
public GameObject Player;
public MeshRenderer meshren;
public float newSize = 0.3f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update() {
size = Player.GetComponent<Collider>().bounds.size;
}
private void OnTriggerEnter(Collider other)
{
print("Entered Trigger");
Player.transform.localScale = new Vector3(size.x + newSize, size.y + newSize, size.z + newSize); //changes size
transform.position = new Vector3(transform.position.x, Player.transform.localScale.y + Player.transform.position.y, transform.position.z); //moves the player up to avoid collision with the ground
objDisappear.enabled = false; //makes the collider not work
meshren.enabled = false; //makes the pellet invisible
}
}