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 GonFreaks · Mar 09, 2015 at 05:21 AM · inputloadlevel

LoadLevel() resets all input to 0! Disastrous!

Dudes!

I've built this cool and quite extensive 2D action platformer, like Super Meat Boy. Whenever the player die, I reload the scene to automatically reset all the gameMechanics.

However, against my will, all player input is set to 0.

If the player was running right, holding leftctrl for running, when the scene is reloaded he should automatically start running again.

But what happens is that he stands still, and you have to lift your fingers off the buttons and then press them again to make it register.

This is so cumbersome, and really ruins the speed and pace of the game for me.

 float h = Input.GetAxisRaw("Horizontal");
 control = Input.GetKey (KeyCode.LeftControl);

Are there any workarounds to this date? To manually reset everything in the scene is such an ultra cumbersome solution.

Can you somehow cash the inputs and carry them over to the next scene? I have a singleton gameState object, that can store info if someone knows how to solve this issue!

Cheers, and I hope this post will help other people with the same problem :)

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 AlwaysSunny · Mar 08, 2015 at 08:50 PM 0
Share

"you have to lift your fingers off the buttons and then press them again to make it register"

Evidently, Input starts reading when a level loads; any input that began before that moment will not be considered. As a workaround, you could cache the player's velocity when a level ends, and re-apply it when the next level begins. But the player must still lift-and-re-press their input keys.

If you've proven to yourself that Input won't register already-pressed keys, I'm afraid that's your answer.

avatar image sandeepsmartest · Mar 09, 2015 at 05:35 AM 0
Share

Its better you try to respawn the player at nearest check point rather reloading level.If level is really heavy ,$$anonymous$$y suggestion is to re-spawn player.And try to make a method which is responsible for player's movement and try calling it after player's respawn.Hope this helps Thank You Nsk

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiwasi · Mar 09, 2015 at 05:22 AM

I don't think it can be done, not unless you rewrite the input system.

You could cheat and have a message that says "press space to start". That will force the user to take their fingers off the keys and start again.

Alternatively you could reset the level without reloading the scene.

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to clear input after loadlevel on android 2 Answers

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

Clear presses from previous scene 4 Answers

Load scene on button press 4 Answers

Input resets when scene changes 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