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
1
Question by JPB18 · Dec 30, 2011 at 01:16 AM · cameraspacerollthrust

Space Combat Simulator - Camera and Thrust/Roll

Hello there!

//TL;DR

So, I'm new to Unity and I'm trying to make a space combat simulator where the player pilots a fighter using the mouse to set the direction (pitch and yaw), two keys to increase or reduce trust (lets make it "W" and "S") and another two keys to "roll" the fighter (lets make it "A" and "D")...~

With that in mind, I've set up the main camera with a Smooth Follow script aimed at the Fighter, and a Mouse Look script in the fighter. But here is when the problem starts, because, the camera doesn't follows the rear of the craft when I move my mouse on the Y axis, but always follows when I move it on the X axis.

//End TL;DR

So, I've come here searching for help in two things:

  1. How can I make the camera be always looking to the rear of the fighter?

  2. How can I setup the thrust and roll for my fighter?

Thank you very much, and have a good day.

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 Lo0NuhtiK · Dec 30, 2011 at 01:49 AM

For the camera -> Take the smooth follow off of the camera, child the camera to the vehicle, then position the camera where you want it.

For the flight -> quick-code to get you started (UnityScript/Javascript) ->

@HideInInspector var myRigid : Rigidbody ; //used for caching this objects rigidbody   var thrust : float = 100.0 ; var roll : float = 100.0 ;   function Start(){ myRigid = rigidbody ; }   function Update(){ FlyMeToTheMoonAndLetMePlayAmongstTheStars(); }   function FlyMeToTheMoonAndLetMePlayAmongstTheStars(){

//roll control for left/right arrow keys, and/or 'a'/'d' myRigid.AddRelativeTorque(0,0, Input.GetAxis("Horizontal") (roll Time.deltaTime)) ;

//thrust control for up/down arrow keys, and/or 'w'/'s' myRigid.AddRelativeForce(0,0, Input.GetAxis("Vertical") (thrust Time.deltaTime)) ; } //NOTE : the "Input.GetAxis...." parts might need changed to a negative value, I can't remember what the default buttons are for negative/positive axis. //e.g. if you push left, but it rolls right, change it to " - Input.GetAxis.... "

Comment
Add comment · Show 6 · 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 · Dec 30, 2011 at 02:22 AM 0
Share

Thank you very much the part of the Thrust is now beginning to look good, and the camera is now behind the fighter (the roll still ain't work, though)...

If you don't $$anonymous$$d I make another question is on how to smooth the camera turn a bit so that it makes a bit of angle from the fighter, but always keeps the thrusters focused?

avatar image JPB18 · Dec 30, 2011 at 02:51 AM 0
Share

Nope, reached to increase the value up to 1000000.0 and still no Roll...

avatar image JPB18 · Dec 30, 2011 at 02:59 AM 0
Share

So is there a way to keep the F-302 pointing at the mouse, and "Roll"?

avatar image JPB18 · Dec 30, 2011 at 03:27 AM 0
Share

Well I've found out someone with exactly this problem... $$anonymous$$aybe this would fix it?

http://answers.unity3d.com/questions/18534/rotating-local-z-axis-roll-on-a-mouselook-or-simil.html

Or is there a better way?

avatar image Lo0NuhtiK · Dec 30, 2011 at 03:35 AM 1
Share

Idk lol go ahead and give it a shot. I just like trying to figure out the code myself to learn along the way. Trial and Error $$anonymous$$ches me more than copy/paste :D
Edit : For anyone else viewing this, shortly after posting the code above @JPB18 and I discovered that the mouse-look script interferes with the code when they're both being used. I deleted my part of the conversation because I don't like to leave a bunch of posted comments everywhere.

Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to slow down a spaceship using C#? 1 Answer

How spaces works in unity? 1 Answer

Move in direction of mouse look 2 Answers

Uneven camera movement during roll 0 Answers

How can i center the camera to a moving object using space? 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