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 slideinsideways · Mar 17, 2013 at 06:13 AM · 3rd person controller

3rd person controller - stopping animation on death

I am looking for a good technique to stop the looping idle animation after I play my death animation on a 3rd person controller. Currently the character dies and falls over, but then bounces right back as idle anim kicks in looping.

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 Professor Snake · Mar 17, 2013 at 08:29 AM 0
Share

Without your script that handles character animation, little can be done. Although the solution is as simple as checking whether the character is dead before animation.CrossFade("Idle"); .

avatar image slideinsideways · Mar 18, 2013 at 04:31 AM 0
Share

script below. I am killing the character with "P" in this example. I am currently using ClampForever to stop animation on death. This still allows me to move the dead guy around with the controller.

I am comfortable scripting the state engine for the character, detecting death after X damage for example.

The more specific question I have is, what is the best practice for 'killing' the character's 3rd person controller from the standpoint of animation, movement, etc. Should you destroy the object and create new to re-spawn? I know these are big topics. I am new and just looking for some pointers or references I should look into.

function Start () { animation["attack3Weapon"].layer = 1; animation["attack3Weapon"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;

animation["attack3HitCombo_BWeapon"].layer = 1; animation["attack3HitCombo_BWeapon"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;

animation["deathWeapon"].layer = 1; animation["deathWeapon"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.ClampForever; }

function Update () { if(Input.GetButtonDown("Fire1")){ //attack animation animation.CrossFade("attack3Weapon");

// //attack function // var hit : RaycastHit; // if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.TransformDirection(Vector3.forward),hit)){ // Distance = hit.distance; // if ( Distance < $$anonymous$$axDistance){ // hit.transform.Send$$anonymous$$essage("ApplyDamage", TheDamage, Send$$anonymous$$essageOptions.DontRequireReceiver); // } // } }

 if(Input.GetButtonDown("Fire3")){
     animation.CrossFade("attack3HitCombo_BWeapon");
 }
 if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.P)){
     animation.CrossFade("deathWeapon");
 }    
 

}

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by lighting · Mar 18, 2013 at 07:52 AM

I assume you are using Unity 4.0+ with mecanim system. If so create in Animator state machine 2 states for this: Idle and Death. Create one-way transition from Idle to Death and in transition's condition place Death = true, where Death if flag of Boolean type. Then from script you trigger this Death to be true using animator.SetBool("Death", deathFlagInScript) - look for mecanim reference for more details.

Comment
Add comment · Show 1 · 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 slideinsideways · Mar 19, 2013 at 05:52 AM 0
Share

Thanks! I am going through the macanim tutorial now.

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

3rd Person Physics not working? 1 Answer

3rd person controller , movement issues 1 Answer

Players moves with simple script, but dont look where he moves 2 Answers

Pull/share an Object with multiple Rigidbody 3rd person Character controllers 0 Answers

How to get character to face camera direction 1 Answer


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