Freddy
Freddy

Reputation: 1

Teleporting PacMan to other side of the Maze

I'm creating a teleporting for my PacMan game to get to the other side of the maze when triggered. I have the code then but when colliding nothing happens. I need that when i trigger the Left Portal i go to the right portal. I am thinking that the Pathfinding i have might be the problem. Thanks

Portal Code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Portal : MonoBehaviour
{
    public Transform warpTarget;

    void onTriggerEnter2D(Collider2D other){
        Debug.Log("An Object Collided");
        other.gameObject.transform.position = warpTarget.position;
    }
}

Upvotes: 0

Views: 514

Answers (1)

b.galerani
b.galerani

Reputation: 121

Maybe you should check for the methods's name. It must start with an uppercase char instead of an lowercase, so it should be something like this:

private void OnTriggerEnter2D(Collider2D other)
{
     Debug.Log("An Object Collided");
     other.gameObject.transform.position = warpTarget.position;
}

Upvotes: 2

Related Questions