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 JPB18 · Jul 24, 2012 at 04:49 PM · rotationjavascriptmovementspeed

Object doesn't turn at the desired rate

Hi there!

I'm doing this script to control a ship in a 3D environment. However, when I try to change the speed rotation, the rotating speed is just to slow, and even if I make the rotation happen at a 360º per second, it rotates at the same speed as if I had set it at 90º per second.

Also, when I change the speed direction, instead of going forward on it's own Z axis, the ship conserves its direction.

Here's the code:

 //Horizontal Axis control ship left-right direction, Vertical Axis control top-bottom direction, ShipSpeed Axis controls the speed of the ship.
 
 //these are to be replaced through stored variables (maybe in a XML file)
 var agility : float = 90.0; //Agility of the craft, soon to be controled through stored variables. In degrees per second.
 var speed : float = 10.0; //Speed of the craft, soon to be controled through stored variables
 
 
 
 function Start () {
 
 }
 
 function Update () {
  //Movement
  //obtain movement variables
  var vert = Input.GetAxis("Vertical") * agility * Time.deltaTime;
  var horz = Input.GetAxis("Horizontal") * agility * Time.deltaTime;
  var fwd = Input.GetAxis("ShipSpeed") * Vector3.forward * speed;
  
  
  //here we rotate the ship
  transform.Rotate(vert,horz,0);
  //give speed to the ship
  rigidbody.AddRelativeForce(fwd);
  
  
  
 
 }

So how can I fix those issues?

Thanks in advance for the anwers.

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
0
Best Answer

Answer by Artifactx · Jul 24, 2012 at 05:42 PM

have you tried to calculate your speed like this:

 public var speed : float = 10.0;
 
     var amoutToMove : float;
     
     function Update()
     {
       amoutToMove = speed * Time.deltaTime;
     
     vad = Input.GetAxis("ShipSpeed") * Vector3.forward * amoutToMove;
     }

Not sure about syntax I'm not a Java programmer

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 JPB18 · Jul 24, 2012 at 05:51 PM 0
Share

The problem isn't in the ship speed, however, thanks to your answer, I noticed the lack of the "Time.deltaTime". Thanks.

However my issue is still unsolved. The ship changes direction way to slow, and when it changes, it keeps going forward in the original direction unless the player keeps actioning the "ShipSpeed" Axis.

avatar image Artifactx · Jul 24, 2012 at 06:03 PM 0
Share

I'm not sure if it will work, but have you tried to calculate the agility the same way as I calculated amoutTo$$anonymous$$ove?

$$anonymous$$aybe you sould also translate the ship ins$$anonymous$$d of using the rigidbody.

avatar image insominx · Jul 24, 2012 at 06:15 PM 0
Share

It might help if you understood the numbers a little better. Check out the explanation here: http://www.youtube.com/watch?v=QbdpOau$$anonymous$$AQg

avatar image JPB18 · Jul 24, 2012 at 07:02 PM 0
Share

Hmm, I guess that helped... Thank you!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotation used as movement 4 Answers

rotation speed cap in 2D 0 Answers

Speed limit? 2 Answers

Speed of player depends on angle of rotation 1 Answer

Make object move in the direction is facing when rotated 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