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 Digipyro · Nov 30, 2010 at 08:57 PM · animationbuttongameblending

Several animations under 1 key

Dear unity community, i've been working on a fact paced Action RPG for quiet a while now and recently stumbled upon a problem. As a rookie scripter i cant see what i've done wrong. i'm trying to make the character have an attack sequence with several animations. So press fire 1 once triggers animation 1 press it again within an X ammount of seconds will trigger animation 2 ( unless your too late ) Now with this script it wont even finish the full animation on animation 1 but neither trigger animation nr2 while it does print and show the texture.

i know it's quiet a pill but i would really appriciate the help i've tried several methods of calling up the script: animation.Blend / Animation.CrossFade etc etc here is the script i hope anyone could take the time to read through it and help me out.

var punchSpeed = 1; var punchHitTime = 0.6; var punchTime = 0.4; var punchPosition = new Vector3 (0, 0, 0.8); var punchRadius = 1.3; var punchHitPoints = 1; var combo1 = true; var combo2 = false; var combo2time:float=0.00; var combotexture: GUITexture;

private var busy = false;

function Start () { combotexture.enabled = false; }

function LateUpdate () { var controller : ThirdPersonController = GetComponent(ThirdPersonController); if(!busy && Input.GetButtonDown ("Fire1") && controller.IsGroundedWithTimeout() && !controller.IsMoving()) {
SendMessage ("DidPunch"); busy = true; } if (combo2==true&&Input.GetButtonDown ("Fire1")) { print("it works"); animation.CrossFade("P_Hit - 3", 1); //animation.Blend("P_Being hit",1); } }

function DidPunch () { if (combo1==true)animation.Play("P_Hit - 1"); yield WaitForSeconds(punchHitTime); var pos = transform.TransformPoint(punchPosition); var enemies : GameObject[] = GameObject.FindGameObjectsWithTag("Enemy");

 for (var go : GameObject in enemies) {
     var enemy = go.GetComponent(EnemyDamage);
     if (enemy == null) continue;

     if (Vector3.Distance(enemy.transform.position, pos) < punchRadius) {
         enemy.SendMessage("ApplyDamage", punchHitPoints);
         SendMessage("attack1");
         //yield WaitForSeconds(0.5);
     }
 }
 yield WaitForSeconds(punchTime - punchHitTime);
 busy = false;

}

function attack1() { combo1 = false; combo2 = true; SendMessage ("combo2_active"); }

function combo2_active() {
combotexture.enabled = true;

 yield WaitForSeconds (combo2time);
 combo1 = true;
 combo2 = false;
 combotexture.enabled = false;

}

function OnDrawGizmosSelected () { Gizmos.color = Color.yellow; Gizmos.DrawWireSphere (transform.TransformPoint(punchPosition), punchRadius); }

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 Digipyro · Nov 30, 2010 at 09:00 PM 0
Share

Sorry for the mess it leaves :S .... tried clearing it but it just messes it up itselve again...

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

Button Opacity Animation Not Working 0 Answers

can an animation be blended between two frames? 1 Answer

Animator has not been initialized?? 3 Answers

How to change UI button animation speed (4.6 UI) 2 Answers

animate sprite in a button event 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