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 /
avatar image
0
Question by superherolamka · Feb 13, 2018 at 09:13 AM · animationscenechange

Changing the scene when animation ends

I have two scenes, called scene 1 and scene 2, with .fbx file.

alt text

If I want to change the scene from 1 to 2 when animation of scene 1 end, how should I do?

capture.png (36.0 kB)
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by yummy81 · Feb 13, 2018 at 09:37 AM

Select the gameobject to which your Animator is attached. Then add the script I wrote for you. Next, go to the Animation Window, look at the timeline and right-click at the keyframe for the clip at the end of which you want your scene to load. Then, from the pop-up menu choose "Add Animation Event". Alternatively you can add event, as shown at this picture:

alt text

You will see a small bar, so left-click it, look at the inspector window and from the dropdown menu choose the function LoadNewScene(). Don't forget to add your scenes to the Build Settings. Here's the code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class LoadMyScene : MonoBehaviour
 {
     public void LoadNewScene()
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene("scene2");        
     }
 }
 
 



picture.png (38.4 kB)
Comment
Add comment · Show 4 · 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 superherolamka · Feb 13, 2018 at 10:17 AM 0
Share

Is it ok for me to have 2 or more objects in one scene?

avatar image yummy81 superherolamka · Feb 13, 2018 at 10:22 AM 0
Share

Of course.

avatar image gitlinjoss · Apr 12, 2020 at 04:25 AM 0
Share

really helpful, did not not know you could do that. FYI, a better way to choose the next scene is to use Scene$$anonymous$$anager.GetActiveScene().buildIndex + 1 to get the next scene and then pass that value into Scene$$anonymous$$anager.LoadScene

avatar image mrbenjamincastro · Nov 02, 2020 at 06:38 PM 0
Share

Trying to add this in, but it is not working. I added in the code exactly, just copy and paste it into a Scripps folder and saved it. Shouldn't it show up in the animation event function?

avatar image
0

Answer by upasnavig90 · Feb 13, 2018 at 09:24 AM

What type of animation is it??, if you are using animations of unity with animators, then you can add event at the end of animation which will load the next scene.

This can Help You, https://docs.unity3d.com/Manual/animeditor-AnimationEvents.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 superherolamka · Feb 13, 2018 at 10:16 AM 0
Share

What do u mean for the type of animation? I used the .fbx files and created 2 objects in both scene 1 and 2.

I want to make a VR app, changing the scene from 1 to 2 without using button when the animation of 2 objects in scene 1 end.

avatar image upasnavig90 superherolamka · Feb 15, 2018 at 07:39 AM 0
Share

yes, then you can use the animation event triggering as i told you. :)

avatar image
0

Answer by TheOrangeNinja2245 · Nov 23, 2018 at 11:46 AM

@yummy81 The script did not work it just comes up as "'default' AnimationEvent 'LoadNewScene()' has no receiver! Are you missing a component?" and i am using Unity 2018.2.16f1. Plz help!

Comment
Add comment · Show 1 · 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 matte94cosimi · Jan 02, 2019 at 06:22 PM 0
Share

@TheOrangeNinja2245 You must add to the void "public". Example: Not Correct
void SceneAfterAnimation() { Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().buildIndex); } Correct public void SceneAfterAnimation() { Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().buildIndex); }

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

213 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 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 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

Animation play when player collides/hits an GameObject 0 Answers

After I move to my object(via arrow keys) and it is destroyed how to play the animation 0 Answers

Sprite Facing Responds Late 0 Answers

Access Mecanim States and change animation 1 Answer

How do I load a new scene based on current scene? 3 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