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 /
  • Help Room /
avatar image
0
Question by FlyingRonin · Aug 19, 2020 at 11:30 AM · jumpingplayer movement

player jumping issue

public class Player : MonoBehaviour { [SerializeField] private Animator animator;

 public int maxHp = 100;
 public int currentHp;
 public StaminaAndHpHandler healthBar;
 public StaminaAndHpHandler staminaHandler;
 public bool isRunning = false;
 private int sprintTime = 1;

 [SerializeField]
 private float _speed = 3f;
 private float _horizontalSpeed;
 private float _horizontalMovement;

 [SerializeField] 
 private UIManager _uiManager;
 [SerializeField]
 private PlayerCombat _playerCombat;

 [SerializeField]
 private object boxCollider2D;

 [SerializeField]
 private new Rigidbody2D rigidbody;
 [SerializeField]
 private Rigidbody2D rb2d;

 private bool isGrounded;
 public Transform feetPos;
 public float checkRadius;
 public LayerMask whatIsGround;
 public float jumpForce = 10f;

 void Awake()
 {
     rb2d = transform.GetComponent<Rigidbody2D>();
 }
 void Start()
 {

     currentHp = maxHp;
     healthBar.SetMaxHealth(maxHp);

     rigidbody = GetComponent<Rigidbody2D>();

 }

 private void FixedUpdate()
 {


     PlayerMovement();


 }
 void Update()
 {

     isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);

     if (isGrounded == true && Input.GetKeyDown(KeyCode.Space))
     {
         rb2d.velocity = Vector2.up * jumpForce;
     }

 }


 void PlayerMovement()
 {

     if (Input.GetKey(KeyCode.LeftShift) && _horizontalSpeed != 0 && staminaHandler.currentStamina > 0 )
     {
         isRunning = true;

         animator.SetBool("Run", true);

         staminaHandler.Running(sprintTime);

         _speed = 5f;
         
     }

     else
     {
         isRunning = false;

         animator.SetBool("Run", false);

         _speed = 3f;

     }

     _horizontalSpeed = Input.GetAxisRaw("Horizontal") * _speed;

     Vector3 _horizontalMovement = new Vector3(Input.GetAxis("Horizontal"), rb2d.velocity.y, 0f).normalized;

     animator.SetFloat("Speed", Mathf.Abs(_horizontalSpeed));


     
         
     
     if (!this.animator.GetCurrentAnimatorStateInfo(0).IsTag("Attack"))
     {
         rigidbody.MovePosition ((Vector3)transform.position + (_horizontalMovement * _speed * Time.fixedDeltaTime));
     }
     //Stops movement when attacking



     Vector3 characterOrientation = transform.localScale;

     if (Input.GetAxis("Horizontal") < 0)
     {
         characterOrientation.x = -1;
     }
     if (Input.GetAxis("Horizontal") > 0)
     {
         characterOrientation.x = 1;
     }

     transform.localScale = characterOrientation;

 }

 public void DamageTaken(int damage)
 {
     currentHp -= damage;

     healthBar.SetHealth(currentHp);
 }



   

}

this is my entire player code since i can't seem to be able to find the issue. Basically i try to jump but the character is always glued to the ground no matter what except when i click attack.

also i've tried multiple variations but didn't work well either so maybe a change in how my movement is detected is needed...idk

Comment
Add comment · Show 1
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 xxmariofer · Aug 19, 2020 at 09:23 AM 0
Share

we cant debug for you

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FlyingRonin · Aug 19, 2020 at 09:25 AM

Well I'm not exactly asking for a debug. Thanks anyways.

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

212 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

Related Questions

Jump not working in my Player Movement Script 1 Answer

Change the "jumping speed" in the FirstPersonController by using another script 0 Answers

Jumping Problems 0 Answers

Unity52D - Player Jump Bug 0 Answers

How come I can't jump?,How Come my script won;t actually let my character jump??? 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