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 /
This question was closed Feb 22, 2015 at 10:28 PM by tanoshimi for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by SputnlK · Feb 22, 2015 at 04:18 PM · transformvelocityspeedfixedupdateacceleration

Acceleration of Transform in FixedUpdate (SOLVED)

im trying to get the acceleration of the transform of a gameobject in FixedUpdate. i need it for a raycast wheel i am trying to create. i already get the velocity of it through a code i found in the web. ive been searching all day now and i still havent figured out how to calculate the acceleration of a transform.

here is what i used to calculate the transform's velocity:

 IEnumerator CalcVelocity()
 {
     while (Application.isPlaying)
     {
         // Position at frame start
         prevPos = transform.position;
         // Wait till it the end of the frame
         yield return new WaitForSeconds(Time.fixedDeltaTime);
         // Calculate velocity: Velocity = DeltaPosition / DeltaTime
         currVel = (prevPos - transform.position) / Time.fixedDeltaTime;
         localVel = transform.InverseTransformDirection(currVel); 
     }
 }

(sorry, can't figure out how to make a code sample)

thanks if you take time to help me

EDIT: this is how i solved it:

 IEnumerator CalcVelocity()
 {
     while (Application.isPlaying)
     {
         Vector3 pos1 = transform.position;
 
 
         yield return new WaitForFixedUpdate();
 
         Vector3 pos2 = transform.position;
 
         Vector3 vel1 = (pos1 - pos2) / Time.fixedDeltaTime;
 
         deltaPos = pos1 - pos2;
 
         currVel = vel1;
 
         localVel = transform.InverseTransformDirection(currVel);
 
 
         yield return new WaitForFixedUpdate();
 
         Vector3 pos3 = transform.position;
 
         Vector3 vel2 = (pos2 - pos3) / Time.fixedDeltaTime;
 
         Vector3 acc = (vel1 - vel2) / Time.fixedDeltaTime;
 
         currAcc = acc;
 
         localAcc = transform.InverseTransformDirection(currAcc);
 
 
     }
 }








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

  • Sort: 

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How do I create a rubber band effect on a camera forward movement? 1 Answer

How to control acceleration 3 Answers

Help around an approach to a "Virtual Motion Table" in Unity 0 Answers

Advice controling speed of a rigidbody 1 Answer

How to increase and decrease the animation speed? 1 Answer


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