I can't figure it out.

I have done everything I can to create a SceneChanging script. There are no error, I set it as Trigger, I gave the player a Collider and it just doesn’t work. I would love is somebody would try my game out and tell me what the error is.
A link to it is here: FPS_openworld.1.unity

PS! Important: The teleportation block is the Gold block on top of the hill. The player is a FPSController named “Player”. To get up there either solve the puzzle, or place the Player up on the mountain. Thank you very much!

Hello there,

Could you give us a little more information please? Like post your code, tell us what you are trying to do, describe which components are on your objects, etc… We can’t help you if your question is that vague.

Other than that, you also need to upload the actual project (or a build) if you want us to test it. A scene file can’t work without your scripts, assets, settings, etc…


UPDATE:

Site wouldn’t let me post a new comment, so here it is:

I didn’t make a prefab per say, but this will help you regardless. Just make a new script and call it “OnCollisionLoadScene”. Then, you can place it on your cube.

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

[RequireComponent(typeof(Collider))]
public class OnCollisionLoadScene : MonoBehaviour
{
    [SerializeField] private string sceneToLoad = "";

    //Check Collision against all tags in this list
    [SerializeField] private List<string> list_tagsToWatchFor = new List<string>();

    // Enable OnCollisionEnter
    [SerializeField] private bool checkForCollision = false;
    // Enable OnTriggerEnter
    [SerializeField] private bool checkForTrigger = false;
    //Enable DistanceCheck
    [SerializeField] private bool checkForDistance = false;
    [SerializeField] private float distanceToCheck = 0.0f; // Radius to check
    [SerializeField] private float distanceCheckRefreshEvery = 0.0f; // Check for distance every X seconds

    private void Start()
    {
        if (checkForDistance)
            StartCoroutine(CheckForDistanceCoroutine());
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (!checkForCollision)
            return;

        if (list_tagsToWatchFor.Contains(collision.gameObject.tag))
        {
            Debug.Log("COLLISION: LOAD SCENE");
            SceneManager.LoadScene(sceneToLoad);
        }
    }

    private void OnTriggerEnter(Collider collision)
    {
        if (!checkForTrigger)
            return;

        if (list_tagsToWatchFor.Contains(collision.gameObject.tag))
        {
            Debug.Log("TRIGGER: LOAD SCENE");
            SceneManager.LoadScene(sceneToLoad);
        }
    }

    private IEnumerator CheckForDistanceCoroutine()
    {
        while (checkForDistance)
        {
            List<GameObject> objectsToCheck = new List<GameObject>();
            foreach (string item in list_tagsToWatchFor)
                objectsToCheck.AddRange(GameObject.FindGameObjectsWithTag(item));

            foreach (GameObject item in objectsToCheck)
            {
                if (Vector3.Distance(transform.position, item.transform.position) <= distanceToCheck)
                {
                    Debug.Log("DISTANCE: LOAD SCENE");
                    SceneManager.LoadScene(sceneToLoad);
                    break;
                }
            }

            yield return new WaitForSeconds(distanceCheckRefreshEvery);
        }
        yield return null;
    }

    //Purely for distance vizualisation in the scene
#if UNITY_EDITOR
    private void OnDrawGizmos()
    {
        Gizmos.color = new Color(0.65f, 0.0f, 0.0f, 0.25f);
        Gizmos.DrawSphere(transform.position, distanceToCheck);
    }
#endif
}

• The collision works IF your player has a Collider NOT trigger and a rigidbody.

• The TRIGGER collision works IF your player has a Collider trigger and a rigidbody.

• The distance check works continuously as long as you have it enabled.

Don’t forget to fill the fields you need in the inspector before using it!


Hope that helps!

Cheers,

~LegendBacon