Building a simple platformer, is there way for unity to detect where on the platform the player collides- so the platform destroys itself? I want the platform only destroyed if the player lands on top of the platform. If the player collides on the side, or bottom, i don’t want the object (platform) destroyed.
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
using System.Collections;
public class DisappearingPlatform : MonoBehaviour
{
public GameObject playerLocater;
// Use this for initialization
void Start ()
{
playerLocater = GameObject.Find("test");
}
void OnCollisionEnter(Collision disappearingPlatform)
{
if (disappearingPlatform.gameObject == playerLocater)
{
Destroy(gameObject);
}
}
}