I would like to make only the player object able to collide with a simple box collider meant to keep the player from falling below the camera. All other objects should be able to pass through the box colider though. I made an IgnorePlayer script to attach to the box collider and it is meant to ignore enemyship3 but it isn't working yet.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ignore : MonoBehaviour {
public Transform objectToIgnore;
// Use this for initialization
void Start () {
Transform bullet = Instantiate(objectToIgnore) as Transform;
Physics.IgnoreCollision(bullet.GetComponent(), GetComponent());
}
void Update () {
}
}
I know that I could make the enemy ships on a different layer but I also would like for enemyship3 to be able to collide with the player object just not the collision box that holds the player object from falling.
↧