Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by jonahsrocket · Aug 02, 2016 at 09:18 PM · colliderscenetagontrigger

Change scene

Hi there,

I made a 2d cube and i attached a script that if you click the cube, the Player game object walks towards the cube. That works.

Now I want to change the scene as soon as the player hits the cube. If found this script which should work.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.SceneManagement;
 
 public class SwitchLevel : MonoBehaviour {
 
     public string levelToLoad;
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     void OnTriggerEnter(Collider other)
     {
         if(other.tag == "Player")
         {
             SceneManager.LoadScene(levelToLoad);
         }
     }
 }

But when the Player hits the cube, no new scene is loaded.

I have attached the Player-tag to the player game object (which walks towards the cube), i placed the name of the scene in the empty box in the inspector and attached a box collider to the cube and the player en made the cube a trigger.

I hope someone can help me out with this problem. Thank you in advance!

Cheers,

Jonah

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mrwmrutski · Aug 02, 2016 at 09:48 PM

    void OnCollisionEnter(Collision myCollision)
      {
      if(myCollision.gameObject.tag == "Player")
      {
      Application.LoadLevel("Scene Name");
      }
      }

I found this laying around and is not mine: Answer by Vice_Versa · Sep 14, 2015 at 01:13 AMhttp://answers.unity3d.com/questions/1066454/on-collision-enter-next-scene.html link text

I myself am a Very newbie but this example is naming the Collision to the game Object being the active player. Your example is vague left opened, if you get my point, insert it and SEE?? It is my guest and only offered as I am learning as I go. Hope it helps you out ...Peace..... PS reply back if it does,thanks

[1]: http://answers.unity3d.com/questions/1066454/on-collision-enter-next-scene.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jonahsrocket · Aug 03, 2016 at 08:08 AM 0
Share

@mrwmrutski Thank you for answering.

Newbie myself also ;)

Too bad, this didn't work. What I read in tutorials is that the code you posted doesn't work in Unity 5.3. When you attach it, Unity tells you that you have to use Scene$$anonymous$$anager.LoadScene. So it gives an error.

I have a feeling that my problem may not be the code but has to do with that the colliding of the two objects doesn't work correctly.

I'll dive into that. Thanks anyway!

avatar image taterbot4 · Nov 11, 2020 at 04:20 PM 0
Share

it did'nt work

avatar image
0

Answer by jonahsrocket · Aug 09, 2016 at 10:47 AM

I found the solution using a javascript code that i found here:

https://www.youtube.com/watch?v=vcFtoiWZ86w

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mrwmrutski · Aug 09, 2016 at 04:53 PM 0
Share

@jonahsrocket COOL!! Glad you found your answer and good luck with the rest of your project. $$anonymous$$e, I have been going back and forth between $$anonymous$$icrosoft`s Virtual Academy for (absolute beginner) C# and Video Studio. Also PixelNests and Ray Wenderlich`s site for Unity w/C# for game development. I have some HT$$anonymous$$L5 and Processing / Processing-JS knowledge. But this is all new to me, and a bit over whelmed. Though very excited at the same time. Will just have to endure the newbie growing pains and Practice, Practice and more Practice!!!

Good Luck to you with the rest of your works and ...Peace.....

avatar image jonahsrocket mrwmrutski · Aug 10, 2016 at 07:31 AM 0
Share

@mrwmrutski Yes, it is pretty hard to get into this. I know a bit javascript and html5 also but I am a newbie with C#. I also experience the same you do, getting the right info is not allways easy. But I am happy that I did not give up. Every (tiny) step forward makes me happy that I am getting to where I want to be. But it's taking time (and a lot of patience).

On the more positive side: The forum here is very helpfull. I wouldn't know how to get forward without it.

You also good luck with getting to know Unity! Cheers!

avatar image mrwmrutski jonahsrocket · Aug 10, 2016 at 05:52 PM 0
Share

Just offering this up as something to look at. I am not pushing their stuff but not to share these. As a possibility for you to get something from them would be selfish. The first is a Free and fully explained step by step video for learning and working with C#. He really takes his time explaining in detail every nut and bolt of it. The second is $$anonymous$$SDN for documentation on C#, many options and links. All Free and you can export them completely or by chapters to your drive. To study from off-line or where ever. Both are from $$anonymous$$icrosoft : Virtual Academy and $$anonymous$$icrosoft Development Network ($$anonymous$$SDN) It has been very help full and offer a community advice Q/A form.

Just a "do unto others thing I believe in" and without others help, I would be lost myself. Will stay in touch ..... now off to watch a video!! Console.Write("...Peace....."); Console.Read();

link text

link text

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make a growing mesh 0 Answers

Failed to create agent because it is not close enough to the NavMesh 4 Answers

Compare Tag on Collision (Collider.CompareTag) 2 Answers

I have several scenes in 3D, and I want them to change after colliding the player with an object. How do I do this? 1 Answer

Need Help With Collider Script. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges