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 /
avatar image
0
Question by Menethil · Sep 18, 2011 at 09:20 AM · timespacedeltatimeshiphigh

High Speed

I'm making a spaceship for my game and I'm using that code to control the ship ;

var Ucak:Rigidbody; var speed:int=5; var speedu:int=5; var speedd:int=5; var speedr:int=5; var speedl:int=5; function Update () {

//Ucak.AddForce(Vector3.forward 10); direction=transform.forward Time.fixedDeltaTime * speed; transform.Translate(direction);

if(Input.GetButton("Down")){ transform.Rotate(Vector3.right 25 Time.fixedDeltaTime); direction=transform.up Time.fixedDeltaTime speedu; transform.Translate(direction);

}

if(Input.GetButton("Up")){ transform.Rotate(Vector3.right -25 Time.fixedDeltaTime); direction=transform.up Time.fixedDeltaTime speedd; transform.Translate(direction);

}

if(Input.GetButton("Right")){ transform.Rotate(Vector3.forward 25 Time.fixedDeltaTime); direction=transform.right Time.fixedDeltaTime speedr; transform.Translate(direction);

}

if(Input.GetButton("Left")){ transform.Rotate(Vector3.forward -25 Time.fixedDeltaTime); direction=transform.right Time.fixedDeltaTime speedl; transform.Translate(direction);

} Debug.Log(speedu); }

Ucak means spaceship

And that ship is flying so FAST , so much ... And I looked to the "speed" variable ingame with debug.log and it says speed=5000 but I was set it to 5 ?

How can I fix it ?

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

1 Reply

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

Answer by syclamoth · Sep 18, 2011 at 09:48 AM

You should only use Time.fixedDeltaTime actually inside the FixedUpdate loop - otherwise it will give you funny values. The Update loop happens every frame, whereas the FixedUpdate loop only happens every physics step (however long that is). Try replacing fixedDeltaTime with deltaTime every time you call it- this will give you the correct value.

In fact, there is very rarely any reason to call fixedDeltaTime, since when deltaTime gets called from within a FixedUpdate loop, it returns the fixedDeltaTime anyway! The only time you need to manually specify is if you need to know the exact number for whatever reason, not (as you are using it here) as a way of making your actions framerate independent (as, indeed, it is usually used).

As for your 'speed = 5000' thing, I can't really help you with that one since there is nothing in the code you showed us that could possibly cause such a thing- is there something else that you're not showing us? Remember that the value you assign in the editor will override the value you see in the script, so make sure you haven't done something funny in the inspector.

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Time.deltatime is returning 0? 1 Answer

Accumulating deltaTime oddity 1 Answer

Creating A Ship Customisation/Building System 2 Answers

Time.deltaTime not consistent over time 1 Answer

Time.deltaTime problems? 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