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 /
avatar image
0
Question by RjToni · Aug 30, 2012 at 04:49 PM · animationattack

Simple Attack Script Problem

Hi everybody, I'm trying to learn about unity3d so, I'm making a simple game just to learning.

I'm having a hard time to scripting a attack script. Unity doesn't have a attacking asset, 'cuz it may vary in a game (shoots, swords, kung fu)

Anyway, I've made a script that play the atack animation if I push left ctrl. See below.

function Update () {

if(Input.GetKeyDown("left ctrl")){

animation.Play("attack");

}}

The problem is: It doesn't play the full animation (the animation has 60 frames), so, how can I solve this?

Sorry for de dull question, I really wanna learn the unity scripting, but my way of learning, is praticing.

PS: Sorry for my English, I'm Brazilian.

Comment
Add comment · Show 9
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 kristercollin · Aug 30, 2012 at 05:25 PM 0
Share

Can you tell us how much of your animation is playing? Have you checked that your animation hasn't been cut off for some reason (either in the program you used to make it or in Unity)?

avatar image Fattie · Aug 30, 2012 at 05:38 PM 0
Share

Oi !

A good trick, in the inspector set the animation to play automatically. in that way it will at least play ONE TI$$anonymous$$E when you start the Play button.

So, you can see if your animation is good.

avatar image RjToni · Aug 30, 2012 at 05:45 PM 0
Share

sorry, my mistake.... It wasn't 60 frames, it's just 20, by the way, it's playing just 10, when he draws the sword. I've used maya (i'm beginner in that too), but in maya, the animation goes well. If the animation has been cut in unity, I don't know why. Is there a default play time for an animation? If there is, how can I extend?

Note: If I press repeatly the key, the animation runs in a funny way.

avatar image Fattie · Aug 30, 2012 at 06:22 PM 0
Share

yes, click on animation (apple 6) and you can change the time fairly easily. hope it helps!

avatar image Gilead7 · Aug 30, 2012 at 06:24 PM 0
Share

First, try Get$$anonymous$$eyUp it will happen when you release the key rather than pressing it down. Sometimes that will help. If that doesn't solve anything, you may need to pause for a certain amount of time to make sure it finishes the animation. http://www.burgzergarcade.com/tutorial/hack-slash-rpg-unity3d-game-engine-tutorial/265-unity3d-tutorial-melee-attack-animation-par

This tutorial might help.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by RjToni · Aug 30, 2012 at 10:42 PM

Guys, I DID IT! I've just put the attack animation in another layer, now the animation is going well. I'm still having a problem with the CrossFade, but I'll try another way.

You know, like attack walking or jumping. Maybe I should make a different animation for them, though.

The script is like this:

function Start () {

animation["attack"].layer = 1; }

function Update () {

if(Input.GetKeyUp("left ctrl")){ animation.Play("attack");

}}

Thanks to kristercollin, Gilead7 and Fattie, for your patience and kindness ^__^

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 RjToni · Aug 30, 2012 at 08:14 PM

So, In the inspector, is already in play automatically. I've checked bake animation too ( i'm using IK), and I realize, it's playing just ONE frame, not 10. Even if keep pressed the key down, just play one frame and stops. All the other animations is playing ok (idle, run and jumping)

Comment
Add comment · Show 2 · 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 Fattie · Aug 30, 2012 at 08:16 PM 0
Share

problem could relate to I$$anonymous$$ ?? suggest post new question here, problem with I$$anonymous$$ import $$anonymous$$aya ..?

avatar image RjToni · Aug 30, 2012 at 08:27 PM 0
Share

I'll do that. It's really bugging me, but when I find the solution, I'll post here

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

10 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

Related Questions

Unity3D AI using animations 1 Answer

my animation script does not work 0 Answers

What am I doing wrong with this attack script? 2 Answers

animating character 1 Answer

Switch between idle animations 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