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 question was closed Dec 04, 2014 at 05:09 AM by Prasanna for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by Prasanna · Apr 28, 2014 at 11:08 AM · animationreset

Animation Reset

Hello there, i have restart button in my game, and that button functions working perfectly i reset all variables(all scenes). If i press restart my variables and position getting zero, but my animated objects not working. How cant i reset that thing.

-Prasanna

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

  • Sort: 
avatar image
1
Best Answer

Answer by sumeetkhobare · Apr 28, 2014 at 11:15 AM

Try writing

 animation.Stop();

in your reset button function .

Also Share ur code snippet and your gameobject screenshots

Mark this as solved if the question is solved.

Comment
Add comment · Show 5 · 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 Prasanna · Apr 28, 2014 at 11:27 AM 0
Share

thanks for your reply, already tried this. Its not working.

I added the codes below,

using UnityEngine;

using System.Collections;

public class Dice : $$anonymous$$onoBehaviour

{ private GUIStyle testStyle = new GUIStyle (); public GUIStyle ButtonGUI = new GUIStyle(); public static bool showButton = false; public static int Value, Counter = 0; public Texture2D DiceRoll = null;

 // Turn Based...
 public Texture2D Turn_One, Turn_Two;
 public static bool Roll = true, Check = true;
 public AudioClip RollSound;


 public void OnGUI()
 {
     Vector3 scale;
     float ResolutionX = 1280;
     float ResolutionY = 800;
     scale.x = (float)Screen.width/ResolutionX;
     scale.y = (float)Screen.height/ResolutionY;
     scale.z = 1;
     
     $$anonymous$$atrix4x4 sv$$anonymous$$at = GUI.matrix;
     GUI.matrix = $$anonymous$$atrix4x4.TRS(new Vector3(0,0,0),Quaternion.identity,scale);

 
     if(Counter %2 == 0)
     {
         if(Roll == true)
         {
             GUI.Box(new Rect(0, 490, Turn_One.width, Turn_One.height),Turn_One, testStyle);
         }
         Check = true;
     }
     else if(Counter %2 == 1)
     {
         if(Roll == true)
         {
             GUI.Box(new Rect(1050, 490, Turn_Two.width, Turn_Two.height),Turn_Two, testStyle);
         }
         Check = false;
     }
     if(showButton == true)
     {
         if(GUI.Button(new Rect(550, 710, DiceRoll.width, DiceRoll.height),DiceRoll, ButtonGUI))
         {
             audio.clip = RollSound;
             audio.Play();
             if(Roll)
             {
                 Value = Random.Range(1,7);

                 //Single Player
                 if(Check == true)
                 {
                     Egg$$anonymous$$ove.BoxNumber = Value + Egg$$anonymous$$ove.CurrentBox;
                     Egg$$anonymous$$ove.$$anonymous$$oveClick = true;
                     Egg$$anonymous$$ove.Condition = true;
                 }

                 //Second player...
                 else if(Check == false)
                 {
                     SecondPlayer.BoxNumber = Value + SecondPlayer.CurrentBox;
                     SecondPlayer.$$anonymous$$oveClick = true;
                     SecondPlayer.Condition = true;
                 }

                 //Debug.Log("Dice On");

                 switch(Value)
                 {
                     default:
                     case 1:
                         animation.Play("One");
                         break;
                     case 2:
                         animation.Play("Two");
                         break;
                     case 3:
                         animation.Play("Three");
                         break;
                     case 4:
                         animation.Play("Four");
                         break;
                     case 5:
                         animation.Play("Five");
                         break;
                     case 6:
                         animation.Play("Six");
                         break;
                 }
                 if(Value != 1 && Value != 5)
                 {
                     Counter += 1;
                 }
             }

             else if(Roll == false)
             {
                 //Debug.Log("Dice Off");
                 animation.Stop("One");
                 animation.Stop("Two");
                 animation.Stop("Three");
                 animation.Stop("Four");
                 animation.Stop("Five");
                 animation.Stop("Six");
                 audio.Stop();
             }
             showButton = false;
         }
     }
     else if(showButton == false)
     {
         showButton = true;
     }
 }

}

this script is working fine..

avatar image Prasanna · Apr 28, 2014 at 11:32 AM 0
Share

using UnityEngine;

using System.Collections;

public class Pause : $$anonymous$$onoBehaviour

{ public bool IsPaused = false; public bool ShowButton = true; public bool Exit$$anonymous$$enuButton = false;

 private GUIStyle TestStyle = new GUIStyle ();

 public Texture2D PauseTexure = null;
 public Texture2D PauseScreen = null;
 public Texture2D ResumeTexture = null;
 public Texture2D $$anonymous$$enuTexture = null;
 public Texture2D ExitTexture = null;

 //GUI $$anonymous$$atrix
 
 public void OnGUI() 
 {
     Vector3 scale;
     float ResolutionX = 1280;
     float ResolutionY = 800;
     scale.x = (float)Screen.width/ResolutionX;
     scale.y = (float)Screen.height/ResolutionY;
     scale.z = 1;

     $$anonymous$$atrix4x4 sv$$anonymous$$at = GUI.matrix;
     GUI.matrix = $$anonymous$$atrix4x4.TRS(new Vector3(0,0,0),Quaternion.identity,scale);

     if (ShowButton == true) 
     {
         if (GUI.Button (new Rect (1200, 15, PauseTexure.width, PauseTexure.height), PauseTexure, TestStyle)) 
         {
             GamePlay ();
             ShowButton = false;
             Dice.Roll = false;
         }
     } 
     else if (ShowButton == false) 
     {
         GUI.Box(new Rect (450, 200, PauseScreen.width, PauseScreen.height), PauseScreen, TestStyle);
         if (GUI.Button (new Rect (610, 300, ResumeTexture.width, ResumeTexture.height), ResumeTexture, TestStyle)) 
         {
             GamePause ();
             ShowButton = true;
             Dice.Roll = true;
         }
         if (GUI.Button (new Rect (620, 350, $$anonymous$$enuTexture.width, $$anonymous$$enuTexture.height), $$anonymous$$enuTexture, TestStyle)) 
         {
             Application.LoadLevel ("$$anonymous$$ain $$anonymous$$enu");
         }
         if (GUI.Button (new Rect (605, 400, ExitTexture.width, ExitTexture.height), ExitTexture, TestStyle)) 
         {
             Application.LoadLevel("Exit");
         }
     }
 }

 public void GamePause()
 {
     if (IsPaused == true) 
     {
         Time.timeScale = 1;
         IsPaused = false;
     }
 }

 public void GamePlay()
 {
     if(IsPaused == false)
     {
         Time.timeScale = 0;
         IsPaused = true;
     }
 }

}

In this script i need to restart all other animation in $$anonymous$$enu button

avatar image Prasanna · Apr 28, 2014 at 11:34 AM 0
Share

$$anonymous$$y animation.stop(); is working fine, but i need to restart that animation from start when i pressed that menu button.. I hope u understand the Problem

avatar image sumeetkhobare · Apr 28, 2014 at 12:04 PM 0
Share

try

 animation.Rewind("aniamtion_name");

write this command somewhere in the start() or awake function() in your scene.. so when you load or restart it again, it will rewind and then when you actually play it, it will start from beginning..

also, do one extra thing by following this: 1. select your gameobject which has animation component. 2. hit Ctrl + 6 or open the animation window from 'Window' menu at the top . 3. now, at the topleft, you show be able to find out your 'animation_name' select it. 4. at the bottom-left, you could find an option of how the animation should play. like, Default,Loop,Once,ClampedForever,etc. 5. make sure this option is set to Once, at least not to ClampedForever. the clamped option maintains the position of your animation seek cursor. for more details check the animation script reference and manual reference at unity's documentation.

avatar image Prasanna · Apr 28, 2014 at 01:23 PM 0
Share

Thanks for that Tip, i tried that but again i got the same problem.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

Making an animation play when you press down 2 keys 1 Answer

A node in a childnode? 1 Answer

Blender Animations not working properly. 1 Answer

Can I make animations snap to a frame? 1 Answer

my animation script does not work 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