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 burtonposey · Jan 16, 2012 at 04:21 PM · animationitweenuvmotion

Could use some help with precision UV Tween algorithm

I'm working on developing a fairly particular algorithm, but I think the general utility of it to others could come in hand.

I've been working on a puzzle mechanic where I have a wheel (like in a gameshow) with four colors. My wheel is mapped out so that one color fits within a face on the wheel. There are four colors so the UV space is as follows in the U direction:

  • 0 - 0.25 = color 1

  • 0.25 - 0.5 = color 2

  • 0.75 = color 3

  • 0.75 - 1 = color 4

When the wheel starts spinning, I have a constant rate of speed that I'm applying to the wheel's UV using Material.SetTextureOffset. When the wheel is asked to stop, I start tweening the speed rate down to 0, so it stops. I'm using iTween and to get a nice end effect, I'm also using easeInOutElastic so that it wobbles to a stop.

The problem I can't figure out is how to get the UV to land perfectly in a color range (0.25 per color in the U direction). The shortcoming of my approach is that while it looks great, it doesn't guarantee the precision I need to land completely in a color area. It only controls the speed and the user initiates the stop that starts the speed of the offset of U down to 0.

I'm stumped at the moment for how to solve this. I currently can determine how far off I am from the closest 0.25 increment, so I know if I wanted to click to the nearest color, I could do that.

My question is, how could I use my existing approach, another approach, or some combination of the two, so land perfectly in a 0.25 increment U space and do it gracefully. I really like the elastic effect on the wheel texture stopping and I'm wondering if there's so place in there to maybe stop it and have another tween take over and go right to it. My worry is there will be a disjoint in the motion.

Thanks for the help.

Update: I've uploaded some source files if anyone wants to see what I'm trying to get help with. This shows the panning mechanic and how my existing logic fails to help me pin the stopping point of the tween right on a 0.25 multiple in the UV direction.

Source package

Web Build

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 burtonposey · Jan 17, 2012 at 12:11 AM

I solved this problem with a different solution. During the spinning phase where the player is hands off, I use an animation rate like the method detailed in this post UV Scroller - Step Function. When the user interacts and I need to slow the game wheel down, instead of affecting the animationRate to slow the wheel down, I start affecting the uvOffset value directly (see my source or the previous link) in my OnUpdate function. The UpdateUV function doesn't need to, at this point, apply the animation asset.

The solution is really canned, but the movement is so quick the user is not aware and still the timing of the color that the wheel lands on is the result of skill because I find what color they were in when they stopped the game wheel. I could also do random, but I like to reward players for being quick and dextrous(a la Mario 3 Mushroom Matching Houses).

If anyone has any further questions about this, let me know. I couldn't find a thing on here about timing animations for UV ranges, so I figure this will help someone eventually.

I've posted my source code and working build on my site:

Source package WORKING

Web Build WORKING

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Custom Easing Types using Curves for Motion? 3 Answers

Wing animation 1 Answer

UV Animation export from Maya? 1 Answer

Eyes animation texture problem 0 Answers

Itween and using 2d toolkit animations 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