Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 kataclizm · Dec 02, 2011 at 08:45 PM · inputscenescene-loading

Input.GetAxis returns 0 after scene load

I currently have 2 scenes. When the player object enters a trigger on the right side of one scene, I load the second scene and the player starts on the left side of it. Basic side scrolling type stuff. I would expect if the player continues to hold down the key to move right, then the player object will continue to move.

If the player only holds the right key down, the player object will continue to move right when the next scene loads. Input.GetAxis("Horizontal") returns a value greater than 0.

The problem is if the player jumps or presses any other button before the next scene loads, then, Input.GetAxis("Horizontal") will only return 0. Is there any work around for this? I would expect the player to be able to jump or perform any other action while moving out of a scene, and still be able to get the input on the next scene.

NOTE: If the player releases the key to move right after the next scene loads and presses it down again, Input.GetAxis("Horizontal") will start working again. But I don't feel as though this should be a requirement.

Comment
Add comment · Show 2
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 Jaywalker · Dec 03, 2011 at 04:36 PM 0
Share

you could maybe buffer the pressed key, and then reset it on a getButtonUp?

avatar image boomcallister · Jan 07, 2012 at 08:56 PM 0
Share

Weird, I just came across this same problem. What did you do to resolve it?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by boomcallister · Jan 07, 2012 at 09:47 PM

Weird, I just came across this same problem. Have you resolved it? What did you do?

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 kataclizm · Jan 09, 2012 at 02:31 AM 0
Share
  • I am creating a 2D platformer, so my solution may not work for you if your scenes are very complicated.

Since I do not have Pro (which you can use async scene loading which I believe would solve this problem), this is what I did. It took me some time to code the solution and much testing but it is working perfectly.

1) Every scene has its own folder for storing scene specific prefabs. For example:

/Assets/Resources/Scenes/0_0/

/Assets/Resources/Scenes/0_1/ and so on.

2) All objects in your scene must be prefabs. Any prefabs which can be duplicated are stored in a common place. All scene specific prefabs are stored in the appropriate folder as stated in 1.

3) I have a scene dumper script (Editor Plugin, easy to make) which iterates every object in the current scene and generates a GameObject to Instanciate every prefab in the scene. It saves the full path to the prefab, the position, scale and rotation. This is stored in a file under /Assets/Classes/Generated/ and there is one for each scene. For example if the scene is named 0_0 then it generates /Assets/Classes/Generated/SceneLoader0_0.cs. This file can and will be added as a component when the scene loads.

4) I have an engine object which loads and unloads scenes on the fly. It typically works like this.

  • Get call to load scene.

  • Pauses all objects.

  • Fades screen to black

  • Unloads(Destroy) all GameObjects. (player,engine,camera are maintained)

  • Load all prefabs from the Scenes specific folder. Resources.LoadAll("Scenes/"+scene, typeof(GameObject));

  • Every scene folder contains a prefab which will load that script we generate from the Scene Dumper: It will call somethjing like this. gameObject.AddComponent("SceneLoader_"+scene); This script loads all common prefabs in one shot.

  • Unfade and Unpause the game.

This seems like a lot of work to implement and it has been. But now that the system is in place, creating my levels is very easy. With this solution, I am able to seamlessly load scenes while maintaining character input. If you are interested in going this route, reply with any questions and ill help you out.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Scene inside a Scene 3 Answers

issue with SceneManager.LoadScene 0 Answers

Input refresh between scenes 0 Answers

Is it better to separate Logo and Loading screen into two scenes? or just put them both in one? 1 Answer

UI button loading wrong scene 1 Answer


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