• 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 /
  • Help Room /
avatar image
0
Question by Crueltiesladle · Apr 22, 2016 at 06:18 AM · datadata storagedatastructuredatatype

Looking for the best datatype for a data storing problem

If i had a bunch of values that were possibly non-linear but ordered: 1, 3, 8, 12 and i added a new one, say 5 whats the best collection type (speed over anything else) that would store it between 3 and 8 and gimme the index so i can check whats directly behind that value and in front. it's an animation system, i am storing keyframes and i need to know whats ahead and behind so i can properly interpolate the values

Currently i'm using a hashtable (dicitonary) thats key is the frame number the keyframe was stored at with the value being the position that i want.

So with this method, its very useful for updating a keyframe upon making changes, but upon animating, finding the 3 and 8 if I have placed soem data in 5 has me iterating through the entire list to figure out the index of the current entry and then store the previous and iterate to the next.. (not to mention that everytime i add something to the dictionary, it needs to be sorted by key for this to work).

Just looking for some suggestions to tackle this fairly open ended problem.

To get some insight into my current structure for this animation tool:

I have a component called a timeline, which is what KeyframeProperties record into. So in a keyframeproperty you would call record() and it'd ask the timeline it's connected to if it can record into the current slot, if it can, it'll return the index at which the keyframe was recorded, and then the keyframe property stores that index into a dictionary it currently has with the current data for the animator. When you choose the play the animation, you call the timeline.play() function and it'll handle iterating through all connected properties and calling keyframeproperty.advanceframe(int frame#). This is why i need the previous and next frame, cause without know this, when the frame# is passed in, theres no way to know where the next interpolated destination for an animation should be..

Example: Passed in a 4 and the closest two keyframes in the property are at 3 and 7, the animation should set the starting location to the 3rd frames data, then interpolate to the 7th by 0.25 (1/(7-3) = 0.25)

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

55 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

Related Questions

If there arent Data tables then how?? 0 Answers

What is the best way to achieve local database for mobile? 0 Answers

Some help with Data Save/Load would be most appreciated 3 Answers

Save multiple inputs for one item and print out all items 0 Answers

Keep data between scenes 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges