Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Why Cant I Change Scenes?

Discussion in 'Editor & General Support' started by edwardmchunch462, Aug 19, 2019.

  1. edwardmchunch462

    edwardmchunch462

    Joined:
    Aug 17, 2019
    Posts:
    3
    To explain the code a bit, my script UIElements is what I use to change scenes using buttons. Id usually put the script in and then set it to a specific method when clicked. The code in the other parts of this method chunk works well as it should be. However, I tried reaching one of those methods to change scene when two objects collide. But nothing seems to be happening.
     

    Attached Files:

  2. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    It will be easier to follow if you include the code in your post and use the code tags.

    For a start, I would SetActive to false at the very end, not before other actions.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Often in this case, collisions won't fire unless at least one of the object has a rigidbody on it. Scroll to the bottom of this page for a breakdown of what things cause collisions with what other kinds of things:

    https://docs.unity3d.com/Manual/CollidersOverview.html

    It's a bit dense, and kind of complicated starting off. But one relatively simple thing to do is make sure at least one of the objects has a rigidbody on it, even if the rigidbody is kinematic.

    I assume you're not even seeing the Debug.Log statement being written out? Are both of the object on the "default" layer? (In the inspector, you can see the Layer towards the top right corner when you have the object selected.)

    And a couple more things: Are you sure the "sword" component is on the same game object as the collider? It needs to be on the same object, not a child or parent object. And, you've check the "Is Trigger" checkbox?