I’m creating collectibles for in my 2d platformer, but something’s wrong. I have added a circle collider to my collectible and I checked “Is Trigger.” I added a javascript to my collectible but something is still going wrong. I don’t get any errors or anything, my player just runs straight through the collectible. Here’s my script:
function OnTriggerEnter2d (info: Collider)
{
if (info.name == "player") {
Destroy(gameObject);
}
}
OnTriggerEnter2D needs that D at the end to be capitalized.
Usually, i use this script when it comes to collision :
using UnityEngine;
using System.Collections;
public class Collision : MonoBehaviour {
void OnTriggerEnter(Collider other) {
if(other.tag == “Bullet”)
{
Destroy (gameObject);
Destroy(other.gameObject);
}
else
{
Destroy(other.gameObject);
Application.LoadLevel (“death”);
}
}
}
Hey I found the problem. I was using a script I hadn’t looked into for some time, and it changed is kinematic. I changed that and yay! It works! I’m very sorry to everyone who spent time on this post
stupid me