Buggy teleporters. Teleports work randomly

27 views Asked by At

I will try to be short and to the point. In my project, I am trying to implement the mechanics of teleports through triggers; the trigger code itself looks like this:

public class FarewellHallScript : MonoBehaviour
{
    public int fhCount = 0;
    public Vector3 Teleport_Point;
    public GameObject Player;
 
    void OnTriggerStay(Collider oth)
    {
        if (oth.tag == "FHTrigger"/* && fhCount < 6*/)
        {
            this.transform.position = Teleport_Point;
        }
    }
    void OnTriggerEnter(Collider other)
    {
        fhCount++;
    }
}

or like this:

public class FarewellHallScript : MonoBehaviour
{
    public GameObject Player;
    public Transform _targetPoint;

    private void OnTriggerEnter(Collider other)
    {
        other.transform.position = _targetPoint.transform.position;
    }
}

This script is attached to the player himself and when he enters an object with the appropriate tag, the teleport is triggered. However, I am creating this game for mobile devices, in this case for Android. And for some reason, when I create an assembly of this project on my phone, this trigger no longer works. More precisely, it actually works great, the counter is indicated in the script and it just adds up when the trigger is fired quietly, like any other action, everything except the teleport itself. I can't understand what the connection is. And this is not the only problem, unity is generally very interesting and buggy. Besides this trigger script I have other triggers. But it is the trigger for the teleport that has become somehow common; when I activate other triggers, the counter inside the trigger for the teleport begins to increase, even if I did not touch this trigger, but the teleport does not work. Some kind of magic? I ask experts to help me understand this confusing issue.

I have already reviewed enough tutorials on teleports and no matter what method I use, in my case they all work the same way. That is, as I described above: “it works, but only if I select the teleported object itself (in this case, the character) and for some reason absolutely randomly. When I do the build, it won’t work exactly the same. I don’t understand anything, what’s the matter”.

You can watch demo here: https://www.youtube.com/watch?v=6Cvj0OJNaHU&ab_channel=jebaited

0

There are 0 answers