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 CorpLee · Oct 29, 2012 at 05:47 AM · spacespaceship

Spaceship Control

I have been working on my small space game I have and I got my test ship and a script (below) and got my little ship to fly and twist and all that fun stuff (yay me) But I can't seem to fix the one small problem I have. When I give it power to start moving it just keeps going unless I try to move backwards. Is there some easy way with out having to make another script to make it so that turning, rolling, boosting ect ect. will only keep doing so as long as I am holding it's key?

using this tutorial and script below. http://stopsecretdesign.wordpress.com/2011/09/19/unity-spaceship-tutorial/

What I want it to act like below. from the same guy who made the tutorial http://dl.dropbox.com/u/40580649/Spaceflight/Spaceflight.html

Comment
Add comment · Show 1
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 CorpLee · Oct 30, 2012 at 05:42 AM 0
Share

Where is this meant to be added?

3 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by lil_billy · Oct 29, 2012 at 05:09 PM

ROFL there is no friction in space :D

so if you want it to decelerate you have to make it so

havent you ever watched a space film where the pod is in space and they are rotating it with those little jets on the side and then in order to stop the rotation they fire the jets on the opposite side.

In other words the Fattie was right :D

Now since you seem to be putting emphasis on this being a space controller, if you are going for realism i would keep it the way you have it and force the player to have to manually halt their motions (as they would have to in space). Now if you dont want that you could do as fattie said and apply an opposing force, though doing that is massively inefficient since you would essentially be using a physics calculation to cancel the effects of another physics calculation when you could have just lerped the rotation for a fraction of the processing.

I believe the same guy who made the tutorial you are using also made a regular earth bound flight project. Which you could use that controller and it would be more in keeping with the behaviors you want, just not realistically space flight.

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 CorpLee · Oct 30, 2012 at 12:19 AM 0
Share

Hmmmm thanks for the input guys :) I tried what Fattie said in the below quote and it did nothing that I can see to change my endless spinning and turning etc. Now it did make it so that I can't ever stop the sucker it takes ages to slow it down....

"

var turnspeed = 5.0; var speed = 5.0; private var trueSpeed = 0.0; var strafeSpeed = 5.0;

function Update () {

var roll = Input.GetAxis("Roll"); var pitch = Input.GetAxis("$$anonymous$$ch"); var yaw = Input.GetAxis("Yaw"); var strafe =

Vector3(Input.GetAxis("Horizontal")*strafeSpeed*Time.deltaTime, Input.GetAxis("Vertical")*strafeSpeed*Time.deltaTime, 0);

var power = Input.GetAxis("Power");

//Truespeed controls if (trueSpeed < 10 && trueSpeed > -3){ trueSpeed += power; } if (trueSpeed > 10){ trueSpeed = 9.99; } if (trueSpeed < -3){ trueSpeed = -2.99; } if (Input.Get$$anonymous$$ey("backspace")){ trueSpeed = 0; }

rigidbody.AddRelativeTorque(pitch*turnspeed*Time.deltaTime, yaw*turnspeed*Time.deltaTime, roll*turnspeed*Time.deltaTime); rigidbody.AddRelativeForce(0,0,trueSpeed*speed*Time.deltaTime); rigidbody.AddRelativeForce(strafe);

rigidbody.AddForce( -0.20 * rigidbody.velocity );

}

" I am very new to scripting so maybe I added it in the wrong place? or just need to change the values more.

And I don't want realistic space flight as to the counter trust. As well I looked about for the earth bound flight project you said he had and I could not find anything that was showing how to go about doing it. Do you have a link by any chance?

avatar image
0

Answer by Stopsecret · Oct 31, 2012 at 09:35 PM

Hi, just in case you're curious, I'm the guy who made that script :P First off, thanks for linking me, second off, lil_billy is right, there is no friction in space :) If you want realism, then this script ought to do it. However if you want arcade style, then I recommend (this is important) turning up rigid body drag and angular drag. This ought to make it harder to turn (so turn up the turnspeed, speed, and strafe speed). Hope this helps!

-Stopsecret

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
avatar image
0

Answer by hardcorebadger · Feb 28, 2018 at 08:54 PM

Hey! - not sure if this will help, but for a more arcade-feeling super smooth spaceship controller - this asset might help:

Basically, it has a pretty versatile script to do LERP based cam following of the ship. This is kind of like a normal Smooth Follow, except you get it in full 3D, so the ship can go fully upside down, etc. The controls are easily changeable, which I did myself, but the default is that the ship is continually moving and you use arrow keys for pitch/yaw.

https://assetstore.unity.com/packages/3d/vehicles/space/low-poly-space-ship-ultra-smooth-360-controller-111640

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

13 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

Related Questions

Floating Point wiki script Implementation 2017 0 Answers

Advice on my Ship AI... 4 Answers

Difficulties with "Moving the Space, Not the Player" 0 Answers

Making Top-Down spaceship movement, getting current speed, acceleration, without rigidbody! 1 Answer

Freelancer of Freespace type Enemy Ai 2 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