- Home /
Question by
carrotboardgame · Nov 06, 2021 at 05:22 AM ·
script.colliderscollision detection
Why when player object contact with gameobject (has a box collider) it doesn't trigger OnCollisionEnter?
Here the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class collide : MonoBehaviour
{
public SpikeRestart script;
public GameObject spike;
public Animator animate;
// Start is called before the first frame update
void Start()
{
script = FindObjectOfType<SpikeRestart>();
animate = spike.GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter(Collision collision)
{
if (collision.collider.tag == "Player")
{
animate.SetBool("Hit", true);
}
}
}
Comment
Your answer
