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 ICHeeryI · Jan 26, 2014 at 03:40 PM · speedvector

Speed beetween two vectors

Hi there, I need to calculate speed between two points with a certain time. I have vector(start position) and second vector(that player controls). Sometimes second vector can speed up. After 10 sec second vector will stop. I need to get his speed he had in the movement. Any ideas how can I solve this? Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Jamster · Jan 26, 2014 at 04:01 PM

speed = distance/time :)

The speed is the finalVector - startVector all divided by the time. So:

 float speed = ((endVector - startVector) / 10).magnitude;

EDIT: At least I think that's what you're asking... not so sure reading it back :/

Comment
Add comment · Show 2 · 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 ICHeeryI · Jan 26, 2014 at 07:28 PM 0
Share

I'll test it tomorrow.

avatar image ICHeeryI · Jan 27, 2014 at 08:42 AM 0
Share

Tested and working. Thanks a lot.

avatar image
0

Answer by Josie · Jan 26, 2014 at 08:26 PM

Easy all you need to do is get the first position then the position in 10 seconds and subtract those.

Here is an example in JS

 var FirstPos : float;
 var LastPos : float;
 var speed : float;
 
 var time : float;
 
 function Start () { //If you don't want to measure it from the //start then just do an if statement in function Update
 
 FirstPos = transform.position.y; // Or any other axis
 
 }
 
 function  Update () {
 
 if(time < 10) {
 LastPos = transform.position.y;
 speed = FirstPos - LastPos;
 
 }
 }
Comment
Add comment · Show 1 · 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 Jamster · Jan 26, 2014 at 08:51 PM 0
Share

That's not going to find the speed... that'll find the negative delta movement. Speed is measured in metres per second or miles per hour so will need to have time accounted for somewhere in there. Also the OP asked for vectors not floats.

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

20 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

Related Questions

Unity prediction line renderer 0 Answers

Game Objects same transform.position value, sitting on different places 2 Answers

Rigidbody magnitude 3 Answers

Slowing down a fall from a Jump 4 Answers

Charging up the speed of an game object through a mouse click 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