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 asaf_dangoor · Jun 08, 2017 at 03:31 PM · collision2d-platformerjumpingplayer movement

Unity52D - Player Jump Bug

Hey there,

So basically I am new to everything here, and I am trying to follow a site called Lynda.com. They have a special series of video's about creating an endless runner in Unity 5 2D.

Now as they started with the player I noticed the jump has some critical issue. Since i do not know the syntax or if there is a special feature I have to turn off here on unity I came to ask here.

A video of what the problem is:

https://youtu.be/gKFxLKaKsj8

Basically, that's not supposed to happen, the player should just jump striaght up and if the player gets pushed back a little bit, there is a fix to his X axis pushing him forwards.

Inspector insight - on the player.

http://i.imgur.com/FkcAhSC.png

The only scripts that touch the player:

using UnityEngine; using System.Collections; public class Jump : MonoBehaviour {

     public float jumpSpeed = 240f;
     public float forwardSpeed = 20;
 
     private Rigidbody2D body2d;
     private InputState inputstate;
 
     void Awake ()
     {
         body2d = GetComponent<Rigidbody2D>();
         inputstate = GetComponent<InputState>();
 
     }
 
     void Update ()
     {
     if(inputstate.standing)
         {
             if(inputstate.actionButton)
             {
                 body2d.velocity = new Vector2(transform.position.x < 0 ? forwardSpeed : 0, jumpSpeed);
             }
         }
     }
 }
 



 using UnityEngine;
 using System.Collections;
 
 public class InstantVelocity : MonoBehaviour {
 
     public Vector2 velocity = Vector2.zero;
 
     private Rigidbody2D body2d;
 
     void Awake()
     {
         body2d = GetComponent<Rigidbody2D>();
     }
 
     void FixedUpdate()
     {
         body2d.velocity = velocity;
     }
 }
 



 using UnityEngine;
 using System.Collections;
 
 public class InputState : MonoBehaviour {
 
     public bool actionButton;
     public bool standing;
     public float absVelX = 0f;
     public float absVelY = 0f;
     public float standingThreshold = 1;
 
     private Rigidbody2D body2d;
 
     void Awake ()
     {
         body2d = GetComponent<Rigidbody2D>();
     }
     
     void Update ()
     {
         actionButton = Input.anyKeyDown;
     }
     void FixedUpdate()
     {
         absVelX = System.Math.Abs(body2d.velocity.x);
         absVelY = System.Math.Abs(body2d.velocity.y);
         standing = absVelY <= standingThreshold;
     }
 }
 



I get that I either need to fix something in the inspector or I need to create a script which forces the player not to rotate, but I do not have enough of the syntax for it.

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

0 Replies

· Add your reply
  • Sort: 

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

141 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

Related Questions

How can I fix this with my ground check? 1 Answer

How to check for colliders when teleporting the player in a 2D game? 0 Answers

Help with enemy AI Please! (on 2D Platformer) 0 Answers

i'm making a 2d game, the player can endlessly jumply please help! 0 Answers

I can't do jump in my 2D game 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