I have made a flying cat that follows the player, but I want the cat to be a separate object. Cat is following the player and as soon as it sees a collectible it grabs it for the player and then returns following our player. I have it working, but I need the cat to be a different object, it only triggers properly when it's a child of the player object. I have made two scripts for the cat, one for detection,following following,flying flying and the other for destruction of collectibles.
AI script
void OnTriggerStay2D(Collider2D col){
if (col.CompareTag ("Collectable")) {
//Destroy(col.gameObject, 1F);
if(positionList.Count <= 0){
positionList.Add(col.transform.position);
timerDelay = 1F;
mustReturn = false;
}
}
}
void OnTriggerEnter2D(Collider2D col){
if (col.CompareTag ("Collectable")) {
positionList.Add(col.transform.position);
timerDelay = 1F;
mustReturn = false;
}
}
void OnTriggerExit2D(Collider2D col){
if (col.CompareTag ("Collectable")) {
mustReturn = true;
}
}
Destruction class
void OnTriggerStay2D(Collider2D col){
if (col.CompareTag ("Collectable")) {
Destroy (col.gameObject, 0.5F);
}
}
void OnTriggerEnter2D(Collider2D col){
if (col.CompareTag ("Collectable")) {
}
}
void OnTriggerExit2D(Collider2D col){
if (col.CompareTag ("Collectable")) {
}
}
Question: Why won't the cat function on it's own???
Collectibles DO have that tag, and they DO have a Box Collider 2D along with a 'Trigger: true'
Cat:
