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 /
  • Help Room /
avatar image
0
Question by cbrunstetter · Dec 08, 2016 at 03:00 PM · timespeedmotion

Object Coordinates with timecode

Sorry if this has been covered elsewhere, I was not able to find an answer and I'm new to unity/visual studio.

I have list collection of coordinates for an object which has corresponding timecodes, small example: [{timecode = 0.0122676, x = -1.81340087228691f, y = 34.9939488172236f, z = 5.52542929662983f},{another},{another}, etc].

I have the object moving according to the coordinates, but the speed is incorrect and not realistic. How do I match the motion of the list according to the timecodes and make the motion smooth?

I greatly appreciate the help!

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 hexagonius · Dec 08, 2016 at 06:22 PM 1
Share

to understand you correctly: the object (gameobject) should move to one of these coordinates within the timecode given? Like "move to x,y,z in timecode"?

avatar image cbrunstetter hexagonius · Dec 08, 2016 at 06:30 PM 0
Share

Yes, I am basically trying to accurately simulate the movement of an object from tracking data. I have to make sure it moves smoothly and at the correct speed. The tracking is based off of 30fps, if that helps. Also, there are 49 data coordinates in the list, so a little over a second and a half, I believe.

avatar image hexagonius cbrunstetter · Dec 08, 2016 at 07:35 PM 1
Share

That's quite fast isn't it? I could think of something like this:

 TimeCode[] timeCodeArray;
 int timeCodeIndex = 1;
 float slowDownFactor = 10f;
 float slowedTime;
 
 void Start(){
 slowedTime = Time.time * slowDownFactor;
 }
 
 void Update(){
 slowedTime += Time.time * slowDownFactor;
 while(timeCodeIndex < timeCodeArray.Length
 && slowedTime > timeCodeArray[timeCodeIndex].timeCode){
 timeCodeIndex++;
 }
 
 transform.position = (Vector3.Lerp(timeCodeArray[timeCodeIndex - 1].xyz, timeCodeArray[timeCodeIndex].xyz, (slowedTime timeCodeArray[timeCodeIndex - 1].timeCode) /  timeCodeArray[timeCodeIndex].timeCode)
 };
Show more comments
avatar image hexagonius · Dec 09, 2016 at 07:31 AM 0
Share

I just saw that the lerp code is wrong anyway. it should read something like: lerp(lastCoord, currentCoord, (slowedTime - lastTimecode) / (currentTimecode - lastTimecode))

am on mobile right now, real syntax would be a pain

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.

Follow this Question

Answers Answers and Comments

80 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

Related Questions

How Do I modify speed to be slower? 2 Answers

How to make my powerup last for about five seconds then go back to normal? 3 Answers

How to Get Speed to Very Gradually Pick Up Over Time? 2 Answers

How to change FirstPerson Controller Speed OnTriggerEnter event for a certain amount of time? 0 Answers

Time delay enemy respawn 3 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