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 FullHeartGames · Feb 25, 2016 at 03:40 PM · unitsspeedometermeters

What units are used for the axis. (Speed per Second Script included!) ;-)

So I wrote this simple speed script (feel free to use it if you'd like). My question is what am I calculating is the x-axis in meters therefor m/s. If it helps my vehicle is moving at a moderate speed and am averaging around 30 speed per second.

So this is a pretty crude way of detecting speed, but it is accurate enough for what I need. There are a few limitations,..

1) Only going to work for a 2D game and ignores values of why, you could use the same idea with vector3's i suppose.

2) If you do not want negative values for speed you should use math.Abs when calculating.

 public class SpeedDetection : MonoBehaviour {
 
     GameObject obj;
 
 
     float realPos = 0;
     float currentPos = 0;
     float lastPos = 0;
     
     public float speed;
 
     // Use this for initialization
     void Start () {
 
         obj = GameObject.Find ("objName");
 
         InvokeRepeating ("Speed", 1 , Time.deltaTime * 60);
     
     }
 
     void Speed()
     {
         currentPos = realPos;
 
         speed = currentPos - lastPos;
 
         lastPos = currentPos;
 
 
     }
     
     // Update is called once per frame
     void Update () {
 
         realPos = forkLift.transform.position.x;
 
     
     }
 }
 
Comment
Add comment · Show 2
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 · Feb 25, 2016 at 05:51 PM 0
Share

what is the question again?

avatar image FullHeartGames hexagonius · Feb 25, 2016 at 06:01 PM 0
Share

From one x coordinate to the next how much distance is that in real world units?

1ft, m, km, mile?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Landern · Feb 25, 2016 at 06:04 PM

This concept you need to come up with, some people use 1 meter per unit in Unity, others use different concepts that maybe based off the units in a particular animation/3d modeling software and correlate against Unity's unit system. So in the end, you choose, but make it consistent if the distances over time mean anything to your implementation.

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 FullHeartGames · Feb 26, 2016 at 11:34 AM 0
Share

Yea it's not crucial, more curiosity and a guide to how much I'm exaggerating reality in my game

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how to calculate speed with in range value. 1 Answer

How can I change Sprite Editor Units to Pixels 0 Answers

Units setup in 3ds max 9 Answers

Placing a rectangle above ad 0 Answers

How set 2D velocity in pixels? 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