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 Doggi · Feb 29, 2016 at 12:10 PM · mouseinput.getaxisspaceshipturningflight sim

Space Flight Simulator Turning Problems

Hello.

I am working on a game that involves travel in space, and I am trying to make a flight simulator.

I have it so the space button accelerates ( Rigidbody.AddRelativeForce(0,0,bla*acceleration); ) your ship forwards (z-axis, wherever z is facing based on the particular rotation at that time). I also have it where if you right click, you can move your spaceship in the direction of your mouse (with Rigidbody.AddRelativeTorque (Input.GetAxis("Mouse X"*accelerationTurn, Input.GetAxis("Mouse Y")*accelerationTurn, 0); ).

This is the problem. Say I right click at the right edge of the screen. Then the mouse's local location becomes (0,0). You turn right too fast, and when you attempt to correct your position, you by default move to the center of the screen and move in the desired direction. The problem is that the real axis is dislocated to the right, and this further dislocates your character because you are still in the left side of the axis when you want to go right. Then, you spiral perpetually and have no means of recovery.

Does anyone have a solution as to how to get the axis always in the center of the screen?

Also, I have a max turn acceleration that I am checking for like this:

 if ((ri.angularVelocity.x < maxTurn) && (ri.angularVelocity.x > -maxTurn) && (ri.angularVelocity.y < maxTurn) && (ri.angularVelocity.y > -maxTurn)) {
     ri.AddRelativeTorque (x * rateOfTurnAcceleration, y * rateOfTurnAcceleration, 0);
 }

So this method of constraining the turn velocity actually does deadlock the system so you just can't turn and do the perpetual spiral of death.

If anyone has an answer for how I should handle these problems, which are really the same problem, I will appreciate and +1.

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

0 Replies

· Add your reply
  • Sort: 

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

Input.GetAxis going crazy when I click outside the game window 0 Answers

How can I use both mouse and keyboard to do the same thing? [SOLVED] 1 Answer

Basic character controller not working properly 0 Answers

Why is my Player game object not rotating with mouse movement in 'Survival Shooter' unity project 10 Answers

How to determine the maximum and minimum values of Input.GetAxis("Mouse X")? 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