Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by PersianKiller · Jul 26, 2017 at 08:54 AM · animationspriterandomly

playing animations randomly

as you see they all playing just like each other how can I make them to play randomly? I mean one of them plays at sprite 9, other plays at sprite 2, ..... how can do this very very very simple?

alt text

b1.png (101.7 kB)
Comment
Add comment · Show 6
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 SohailBukhari · Jul 26, 2017 at 09:05 AM 0
Share

you can just record animations and assign different clips or choose random clips from animations and assign clip to the random sprite.

avatar image PersianKiller SohailBukhari · Jul 26, 2017 at 09:14 AM 0
Share

I want to do it with scripts.It would be very good if you show me how to do it.

avatar image SohailBukhari PersianKiller · Jul 26, 2017 at 09:18 AM 0
Share

What you tried in the script?

avatar image PersianKiller · Jul 26, 2017 at 09:26 AM 0
Share

nothing :), I just wonder is that possible or not, I just don't want to make other object ,I want them to play randomly :) and I don't really know how to do that.

avatar image SohailBukhari PersianKiller · Jul 26, 2017 at 09:48 AM 0
Share
 var randomclipName = Animations[Random.Range(0, Animations.Length - 1)];
         foreach (GameObject objects in SpriteGameObjects)
         {
             var anim = objects.GetComponent<Animation>();
             anim.Play(randomclipName.name);
         }
avatar image PersianKiller SohailBukhari · Jul 26, 2017 at 11:14 AM 0
Share

It's a little Complicated. but thanks I have to try it .

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ddmarkas · Jul 26, 2017 at 12:00 PM

In the script attached to this object, you can write in the Start() function :

myAnimator.Play("Default",0,Random.value);

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 PersianKiller · Jul 26, 2017 at 04:32 PM 0
Share

You saved my life man :)

avatar image TheQiwiBoy · Aug 07, 2020 at 02:49 PM 0
Share

THANK YOU SO $$anonymous$$UCH!

avatar image
0

Answer by PersianKiller · Jul 26, 2017 at 01:40 PM

Please explain it clearer I don't get it.

alt text

it's my code but it does nothing.

alt text


b1.png (88.1 kB)
b2.png (2.9 kB)
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 ddmarkas · Jul 26, 2017 at 02:09 PM 0
Share

If you replace "Random.Range(0,5)" by "Random.value", I think it will make the expected behavior.

avatar image PersianKiller ddmarkas · Jul 26, 2017 at 03:04 PM 0
Share

$$anonymous$$ore explain dude , I'm not einstein :).

avatar image ddmarkas PersianKiller · Jul 26, 2017 at 03:28 PM 0
Share

lol, I cannot say much more. Write in the script attached to the coin gameobject :

 void Start()
 {
 GetComponent<Animator>().Play("coin",0,Random.value);
 }

Tell me if this is working.

avatar image
0

Answer by annonymushubh · Jul 26, 2017 at 01:45 PM

make a array and put all the animations on it and generate the Random number as between your array.length() and call the index number animation to play on it

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 PersianKiller · Jul 26, 2017 at 03:03 PM 0
Share

It's just an animation

avatar image
0

Answer by Ki4Chan · Jul 26, 2017 at 03:45 PM

Your question is a little confusing. I think you don't want to start amination from starting all the time. Sometimes you want it to start from the middle or from some other point. Right?

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 PersianKiller · Jul 26, 2017 at 04:28 PM 0
Share

look I have a coin that is prefab. it's animation has 10 sprites, I want to place 5 coin at the scene, then each of them play at random sprites.

I don't want all of them to play from sprite 0,1,2...9

I want one of the plays at 4,5,6... other at 9,0,1...

I think it's a little bit more Interesting if their animations won't play like eachOther. hope you get my idea.

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

186 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 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 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 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 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 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 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 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 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

I want to create an animation with multiple sprites images on a prefab ? 0 Answers

2D sprite character movement 3 Answers

unity gameobject to sprite (UI Image) 1 Answer

Disabling interpolation for Z rotation within animation window? 0 Answers

Dependency sprite animation from the variable 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