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 ozturkcompany · Nov 03, 2013 at 07:02 PM · function update1 frame

How to track an object per Frame?

Hey, i am trying to make a simple tracker for my object which will report the changes on that object,like rotation,scale,position etc.The update is pretty slow which i expected that it would be per frame but it is not.Could you point me out where am i wrong here?The update seems to be close to per second.

Thanks.

var time : float = 0;

function Update () {

if(time < 2) {

//cache the data from object at this time

time += 1;

}

if(time > 1) {

//cache the data from object at this time

time = 0;

}

//compare the caches

}

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 LividRabbit · Nov 03, 2013 at 07:30 PM 0
Share

The Update() function is per frame

avatar image ozturkcompany · Nov 03, 2013 at 07:33 PM 0
Share

Hey, that is true.I am debugging the caches to the consoles and i think there is some delay on there because now it works perfectly fine as i wanted but the update in the editor which made me get confused.

avatar image ozturkcompany · Nov 04, 2013 at 12:08 PM 0
Share

Hi the code above works fine just curios about is there any special function that will do the job in a shorter way?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Huacanacha · Nov 04, 2013 at 07:42 PM

Just store the previous values at the end of each Update function. You don't need the 'time' counter. So the logic for Update() would be:

  • Compare current position, rotation etc to the previous values

  • Do whatever else you want to do in Update

  • Store the current values as 'previousPosition', 'previousRotation' etc

Comment
Add comment · Show 4 · 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 ozturkcompany · Nov 04, 2013 at 07:48 PM 0
Share

Hey thank you very much for taking time and replying. I am a little confused. Are you suggesting to create a new function? Excuse my understanding please

avatar image Huacanacha · Nov 04, 2013 at 08:02 PM 0
Share

Just use some instance variables or Properties (if you can use C#) to store the previous values. Still use the Update() function using the steps I describe above. Here's a C# example (UnityScrips should be very similar) for position only:

 private Vector3 previousPosition;
 
 void Start() {
     previousPosition = transform.position;
 }
 
 void Update() {
     Vector3 deltaPosition = transform.position - previousPosition;  // Change in position from previous frame
 
     // Do whatever you like with the result here, like:
     Debug.Log("  deltaPosition = " + deltaPosition);
 
     previousPosition = transform.position;  // Last line in Update() function
 }
avatar image ozturkcompany · Nov 04, 2013 at 08:07 PM 0
Share

Hi thank you very much! I will try it and will mark your answer Thank you

avatar image valentin56610 ozturkcompany · Feb 19 at 04:38 PM 0
Share

Legend says he never marked it as an answer

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

18 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

Related Questions

How advance animation 1 frame at a time? 1 Answer

Performance of Line Renderer Functions 0 Answers

my object instantiates to much 1 Answer

BCE0023 Error 1 Answer

Breaking a loop, Javascript? 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