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 AlexanderJBaer · May 05, 2014 at 12:08 PM · animationairandomenemy

How do I animate my enemy randomly with time?

Hi there! I am currently struggling to animate my enemy character for a class project. Most of the answers I find about animation scripting are about the player character that animates with inputs or about enemies entering a collision area and then following the player triggering animations on certain cues.

What I am trying to do however is simply play my enemy's animations at random over time. The basic idea is like a whack a mole game that will throw rigid body projectiles at you.

My enemy's possible states are...

  1. Underground ("emerge" animation sitting at frame 1, no animation)

  2. Emerging (plays "emerge" animation)

  3. Idling (plays "idle" animation)

  4. Attacking (plays "attack" animation)

  5. Retreating (plays "emerge" animation in reverse, possible through rewind function / ping pong wrap?)

So in play, I'd like to, at random, have the enemy emerge, idle 1-3 times, attack after idle finishes, maybe idle again, possibly attack again after the idle, then retreat back underground.

Also about 2 seconds after his attack starts he'll spawn a prefab rigidbody that flies towards my characters last known location.

All I'm looking for right now though is how to get the guy to animate without user input or any cues from the player at all. Simply randomly do his motions.

I do not know if this is simple or complex, any help is appreciated, I am coding-impaired.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Noob_Vulcan · May 05, 2014 at 12:24 PM

You Could do Something like this ...

 selectJumpAnim = Random.Range(0,2);
             if(selectJumpAnim == 0){
                 myAnim.Play("jump");
             }
             else if(selectJumpAnim == 1){
                 myAnim.Play("jumpRol");
             }


For doing somethign after some seconds you could use

Invoke("method_name",2.0f);

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

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

21 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

Related Questions

Make AI walk around randomly until Player is Seen. (C#) 2 Answers

Move Enemy randomly in a range. 3D 0 Answers

Enemy Animation Help 0 Answers

Unity3D AI using animations 1 Answer

How can i Learn Basics of Rain AI 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