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 /
This question was closed Feb 14, 2016 at 03:02 PM by Gusic for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by Gusic · Feb 14, 2016 at 02:39 PM · c#animationjumping

Jumping and animation script error.

Hi guys,

I am trying to write a script, so when my character jumps the jumping animation play. But for some reason it doesnt seem to be working.

 using UnityEngine;
 using System.Collections;
 
 public class jumping : MonoBehaviour {
     public bool grounded = true;
     public float jumpPower = 1;
     Animator anim;
     // Use this for initialization
     void Start () {
         anim = GetComponent<Animator> ();
     }
     
     // Update is called once per frame
     void Update () {
         if(!grounded && rigidbody2D.velocity.y == 0) {
             grounded = true;
         }
         if (Input.GetMouseButtonDown && grounded == true) {
             AnimationClip.play("jumping");
             rigidbody2D.AddForce(transform.up*jumpPower);
             grounded = false;
         }
     
 }
 }
 

Thank You.

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 giorashc · Feb 14, 2016 at 02:49 PM 0
Share

what is not working? your posted code cannot even compile as Get$$anonymous$$ouseButtonDown is a method and you treat it as a property. (look here on how to use it)

2 Replies

  • Sort: 
avatar image
0

Answer by Hexicon_Gamezel · Feb 14, 2016 at 05:58 PM

Oh. I just make it so when I press the space bar it will activate the animation, but when I release it. It will go back to idle. This is not the code for jumping this is just an example.

 #pragma strict
 
 function Start () {
 
 }
 
 function Update () {
 
  if(Input.GetKeyDown("w"))
  {
   // Plays the reload animation - stops all other animations
   animation.Play("run", PlayMode.StopAll);
  }
 }

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
avatar image
0

Answer by TreyH · Feb 14, 2016 at 02:48 PM

http://docs.unity3d.com/ScriptReference/ForceMode.html

 rigidbody2D.AddForce(transform.up*jumpPower, ForceMode.Impulse);
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

109 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

Related Questions

Need Help Fixing my Double Jump with Animations in 3D 0 Answers

Animations get screwed up when I add OnAnimatorMove function 0 Answers

Falling blocks skip animation while upside down 1 Answer

How too climb a ladder with the FPS Controller correctly 0 Answers

What type of variable would I declare an animatable object as? (C#) 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