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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Cherikov · Mar 14, 2013 at 12:01 PM · animationcharacterattackanimation.play

Character Animation Assistance

hey guys... I'm looking for some help with my character animation script so far it is:

 #pragma strict
 
 
 function Start () {
 
 }
 
 function Update()
 {
    if (Input.GetAxis("Vertical") > 0.2) 
        animation.CrossFade ("walk");
        else if (Input.GetAxis("Vertical") < 0.2) 
       animation.CrossFade ("idle");
 
 
  if (Input.GetKeyDown ("space"))
 
    animation.Play ("jump");
 
 else if (Input.GetKeyUp ("space"))
 
    animation.CrossFade ("idle", 1);
 
 else if(Input.GetAxis("Vertical") < -0.2){
 
        animation.CrossFade ("walk", - 0.05);
 
    } 
    
   
 }   
 


I apologize for the disorganization of my script but i need help with getting the player to complete the attack function on key "f". whenever i press it it plays for a brief second and then switches to idle. is there someway he will play the animation then switch to idle? please guys i need some help!

Comment
Add comment · Show 2
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 ExTheSea · Mar 14, 2013 at 12:06 PM 0
Share

First mark your code and then press the Code sample button (the one with the 101010) to format your code snippet.

avatar image Cherikov · Mar 15, 2013 at 06:28 AM 0
Share

cheers man!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by VivekD · Mar 15, 2013 at 07:01 AM

Instead of :

 else if (Input.GetKeyUp ("space"))

try using :

 else if (Input.GetKeyUp ("space") && animation.isPlaying("jump") == false)
Comment
Add comment · Show 3 · 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 Cherikov · Mar 19, 2013 at 11:55 PM 0
Share

ok I'll give that a go, Cheers!

avatar image Cherikov · Mar 20, 2013 at 08:32 AM 0
Share

i get an error "it is not possible to invoke an expression of type 'boolean'?

avatar image VivekD · Mar 20, 2013 at 09:13 AM 0
Share

Edited my initial answer. Let me know if that works.

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

12 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

Related Questions

Need help addind a attack and jump script 0 Answers

Script does not work on version 4.6.0. 0 Answers

Adding a Controller, and setting up animations on a Prefab? 1 Answer

Characters Interaction with Mecanim Animations 2 Answers

Root motion / How to bake into pose Root Transform Position (x) 0 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