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 ttcanvas · May 03, 2021 at 07:32 PM · movementcontrollerjump

Jump working in editor runtime but not working in WebGL build

Hello, I wrote a simple script only for first-person-view character to jump. It works pretty well in editor runtime but not in standalone pc build or WebGL build. The code was first in the movement controller script where it had faced similar problem; I took out and tried several things that did not really work. Would you mind sharing any possible methods I should go and check? FYI, I left .isGrounded for the game purpose.

 [SerializeField] private float jumpSpeed = 7.0f;
 private Rigidbody rb;

 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }

 // Update is called once per frame
 void Update()
 {
     float _yMovement = Input.GetAxis("Jump");
     //Apply jump
     if (Input.GetAxis("Jump") != 0 || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.V) || Input.GetKey("space"))
     {
         rb.AddForce(new Vector3(0, _yMovement * jumpSpeed, 0), ForceMode.Impulse);

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HellsHand · May 03, 2021 at 08:36 PM

I'm not certain why this wouldn't work in a Build, unless you are hitting v(see 2), but some suggestions, .

  1. float _yMovement = Input.GetAxis("Jump"); this returns between -1 and 1 so the most you get from your jumpSpeed is 0-7.

  2. _yMovement = 0 if you hit v as it's not a default axis, you can however add it to the Inputs as a secondary positive input under project settings.

  3. GetAxis() is a constant input like GetKey() it triggers for the entire time you are holding it down, so if you hold it down it will add force every frame.

Is it just not doing anything or something you don't want it to do?

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 ttcanvas · May 03, 2021 at 09:03 PM 0
Share

Hi HellsHand, thanks for the suggestions. The reason that I have put 4 similar Get things for the Input was to test if there is something wrong with the keys in build. I added "v" as the secondary positive input and it worked well along with the rest (GetAxis, GetKeyDown, GetKey) in the editor. I already tried multiplying Time.deltatime in Vector3 just in case there are discrepancies in fps between editor and build; I couldn't jump still. I was wondering if there is something to do with Gravity, Dead, or Sensitivity in the input settings and adjusted them from 1000 to 30 for Gravity and Sensitivity while maintaining Dead at -0.0001; nothing worked. Or should I not pursue Addforce and try another option?

avatar image HellsHand ttcanvas · May 04, 2021 at 06:14 PM 0
Share

Can you get it to jump at all? If not have you tried going to extremes, Gravity = 0.0001, mass = 0.00001, jumpSpeed = 200, things like that.

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

179 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Need Scripts for wall forward to behind and climb 0 Answers

Player appears to teleport instead of adding force 2 Answers

Smoothly Jump to mouse position 1 Answer

Character controller jittering up and down 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