Player falls through destroy collider
The player is supposed to be destroyed when falling into the green slime and then the game resets. But instead the player just falls through forever. What is wrong? (I'm new at unity) Pic attached of the box collider. And this is the destroy script for the box collider in the slime:
using UnityEngine; using System.Collections; using UnityEngine.SceneManagement;
public class KillBox : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
}
Answer by M-Hanssen · May 11, 2016 at 10:47 AM
Make sure both objects have colliders on them
Make sure you have a rigidbody attached on either one of the colliders
Make sure the colliders are marked as "Triggers"
If all requirements above are met, it could be the speed which the player falls into the slime collider. In this case set the Rigidbody on KillBox to "Continuous dynamic" collision detection to check for collisions more frequently
Your answer
Follow this Question
Related Questions
GameObject not destroying on Collision 1 Answer
How to move an object on a terrain that will always stay on top of the terrain? 2 Answers
Collision with object not working. 2 Answers
Why Isn't My OnCollisionEnter2D Code Not Working? 1 Answer
Freeze rotation of just the box collider component 0 Answers