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 /
This question was closed Sep 11, 2016 at 09:55 PM by Muki for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Muki · Sep 01, 2016 at 05:31 AM · 2d-platformer

I have this grounded script and it doesn't work

so I have this script but it does not work with my parameter for my player_run and player_jump which grounded parameters. The script works on the player but not on the parameters

using UnityEngine; using System.Collections;

public class PlayerJump : MonoBehaviour { public bool grounded = true; public float jumpPower; private Rigidbody2D myRigidbody;

  // Use this for initialization
  void Start () 
  {
     myRigidbody = GetComponent<Rigidbody2D>();
  }
  
  // Update is called once per frame
  void Update () {
     // Do something
  
       if(!grounded && myRigidbody.velocity.y == 0) {
      grounded = true;
  }
  if (Input.GetMouseButtonDown(0) && grounded == true) {
      myRigidbody.AddForce(transform.up*jumpPower);
      grounded = false;
  }
  }
 
  void FixedUpdate ()
  {
     
     
     
  }

}

Comment
Add comment · Show 4
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 sparkzbarca · Sep 01, 2016 at 05:52 AM 0
Share

what do you mean it works on the player but not on the parameters?

avatar image Muki sparkzbarca · Sep 02, 2016 at 03:37 AM 0
Share

it has a public bool that shows me on my player that i'm grounded but it doesn't work with my animator and the other bool values.

avatar image ToothPaste17 · Sep 01, 2016 at 08:24 AM 0
Share

Try changing your jumpPower to a really high value like 100 or 200

avatar image etaxi341 · Sep 02, 2016 at 11:35 AM 0
Share

Take care with what you are doing! Actually the player can also sometimes reach 0 velocity when he is at the highest point of his jump!

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by b1gry4n · Sep 02, 2016 at 09:54 AM

You need to set the parameters in the animator.

https://docs.unity3d.com/ScriptReference/Animator.html

https://docs.unity3d.com/ScriptReference/Animator.SetBool.html

 public Animator anim;
 anim.SetBool("yourbool", true);
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

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

My Player doesn't move anymore. I didn't change a thing in the script and it did work before. What's wrong? 1 Answer

Animation Problems 1 Answer

How do I create a good Checkpoint system? 0 Answers

Unity 2D - Game Collision Bug Error 0 Answers

Health Bar/Hearts? 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