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 Makenshi · Feb 02, 2011 at 12:36 AM · animationbeginnerloop

Animation loop noob Problem

Hello Right now im trying to use this. this is the script that is just receiving everything

var targetHand: GameObject; var Up: MouseEnterUp; var Down : MouseEnterDown; var ContA : int = 0; var ContB : int = 0;

function Start(){ targetHand= GameObject.Find("As_Hand"); Up= GameObject.Find("CubeUp").GetComponent(MouseEnterUp); Abajo = GameObject.Find("CubeDown").GetComponent(MouseEnterDown); } function Update() { if(Up.EnterA == true) { ContA = 1; } if(Down.EnterB == true) { ContB = 1; }

if((ContA == 1) && (ContB == 1)) { targetHand.animation.wrapMode = WrapMode.PingPong; targetHand.animation.Play("Clean"); // name of the animation clip ContA=0; ContB=0; } }

this is the code that calls EnterA this is another script EnterB is the same thing except that the var is named EnterB and the script is also named different but thats about it

var wasClicked : boolean; var EnterA: boolean = false; function Update() { if(Input.GetButtonDown("Fire1")) { wasClicked=true; } else if(Input.GetButtonUp("Fire1")) { wasClicked=false; Deactivate(); } }

function OnMouseEnter() { if (wasClicked) { Activate(); } }

function OnMouseExit() { Deactivate(); }

function Activate() { EnterA = true; }

function Deactivate() { EnterA =false; }

The animation is playing at first when A and B are both 1 then it loops infinitely any ideas? thank you very much

Comment
Add comment · Show 3
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 tertle · Feb 02, 2011 at 12:40 AM 0
Share

Need to see more, what is setting Up.EnterA and Up.EnterB. Unless you set them to false it's just going to go back into the animation loop.

avatar image Makenshi · Feb 02, 2011 at 12:53 AM 0
Share

k im going to put that code as well

avatar image Makenshi · Feb 02, 2011 at 01:03 AM 0
Share

ok updated hope its better this way :S

2 Replies

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

Answer by zannghast · Feb 02, 2011 at 01:18 AM

This may be the cause (or start of it):

targetHand.animation.wrapMode = WrapMode.PingPong;

With PingPong, the animation doesn't really automatically stop. So unless you explicitly tell it to, the animation won't stop. It would just 'ping pong' back and forth between its beginning and end.

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 Makenshi · Feb 02, 2011 at 01:33 AM 0
Share

yeah that is a good start i tried with wrapmode.once but the problem now is if mouse enters either up or down it plays the animation ins$$anonymous$$d of checking for both :S

avatar image Makenshi · Feb 02, 2011 at 01:48 AM 0
Share

i think im going with this for now i would hope that ping pong could be used that way ins$$anonymous$$d of an infinite loop >.< oh well thank you very much that was very helpful

avatar image zannghast · Feb 02, 2011 at 02:03 AM 0
Share

Did you want the animation to play just once and depending on whether the mouse is 'up' or 'down'?

avatar image
0

Answer by hypnoslave · Feb 02, 2011 at 01:20 AM

woah woah woah! surely this is unnecessary. you've got 2 scripts to look for buttonUp and buttonDown events and flag a boolean variable? Surely you dont need that. What are you trying to do?

It looks like you're just trying to play an animation when the user holds down 2 buttons?

Unless I don't understand something that you're trying to accomplish, you should be able to just use this and only this (frankly, this is probably already a little sloppy):

var hasPlayed : boolean = false; var targetHand= GameObject.Find("As_Hand");

 function Update()
 {
    if(Input.GetButton(x) &amp;&amp; Input.GetButton(y) &amp;&amp; !hasPlayed)
    {
       hasPlayed = true;
       targetHand.animation.wrapMode = WrapMode.PingPong;
       targetHand.animation.Play("Clean"); // name of the animation clip 
    }
    if((Input.GetButtonUp(x) || Input.GetButtonUp(y)) &amp;&amp; hasPlayed)
    {
       hasPlayed = false;
       targetHand.animation.Stop();
    }
 }

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 Makenshi · Feb 02, 2011 at 01:24 AM 0
Share

seems like a good answer im off to try it ty and btw im not trying to get input buttons im trying to check if mouse is entering an object and if it enters top then bottom object then play animation and thats about it :S

avatar image Makenshi · Feb 02, 2011 at 01:33 AM 0
Share

the animation Stop wont work cuz its making it not play the whole animation just like 3 frames or so :S

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

Unity Animation - Loop around a closed loop trajectory 1 Answer

My animation only plays on loop 1 Answer

Abaut Mecanim animation roop 0 Answers

How to change the "average velocity" value in my humanoid animation menu? 0 Answers

Transition Animations at end of current loop 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