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 MajorParts · Sep 28, 2014 at 03:24 AM · cameramousecontrolslookflight

Camera movement independent of player control

My question is...

How do I script for using a mouse to look around without affecting the players rotation?

Using the mouseorbit script does what I expect on it's own, but once a player movement control script is assigned, they affect each other.
Depending on what objects I assign the scripts to, with the player sitting in a cockpit, I either get the mouseorbit moving the cockpit and the flight controls doing nothing, or the mouseorbit works but the cockpit revolves around where the camera is. Does that make sense?
From the initial view looking forward through the canopy, I need to be able to say, look left with the mouse and have the cockpit stay in that position while I carry on flying.

Thanks for looking anyway even if you don't understand what I'm babbling about :)

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 sevensixtytwo · Sep 28, 2014 at 12:31 PM

It's actually quite simple and pretty much depends on how you structure your player object's heirarchies.

For what you're looking for, I may suggest building your "Move" script to use the ship's relative transforms rather than the camera's and then attaching your camera (with its "Look" script) to the ship as a child. In essence, the ship moves, and the camera goes along for the ride.

Hierarchy: Object (Moves and Turns) -> Camera (Looks)

Here's an example of how I used this type of structure: https://dl.dropboxusercontent.com/u/282973338/WebBuild/WebBuild.html

Just tap keys 1-4 to switch positions. Use the mouse to look around and WASD to turn and move the tank.

You can even get creative and do as ARMA does: Mouse turns the entire ship, keeping a button pressed locks the ship and lets you look around the cockpit.

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 MajorParts · Sep 28, 2014 at 03:13 PM 0
Share

Thanks for replying. Yes, that tank thing is very similar. I'm not sure how I can structure things any different though. Currently, I have a gameobject called "Cockpit". Assigned as a child is a group containing the relevant meshes, then another child is a "head" gameobject which has it's own child of the camera. The control script was found here somewhere and asks for "flyer" variable, which I presume to be the "Cockpit" object. The "mouseOrbit" script asks for "Target" variable, which I am again presu$$anonymous$$g, to be the camera (or the "head" object). I can only assume that I'm misunderstanding the "flyer" and "target" variables...or I need to adjust the scripts a certain way. The controls script was found here...link text

The mouseorbit is the included Unity script (I think)

avatar image sevensixtytwo · Sep 28, 2014 at 04:23 PM 0
Share

Yes, well, I would suggest using the $$anonymous$$ouseLook script rather than $$anonymous$$ouseOrbit and putting it on your "head" or your camera. Your flyer script can be put on your "Cockpit" and have it reference itself.

Unless you added mouse Input to the control script, the camera should now be able to look around independently from the rest of the ship.

avatar image MajorParts · Sep 28, 2014 at 04:27 PM 0
Share

Thanks, i'll try the mouselook ins$$anonymous$$d and see. I'm beginning to think that flightcontrols script doesn't work properly anyway, as if I add objects to the scene, like cubes just hanging there to shoot at, they seem to move with the controls as well (to a certain extent)...I have no idea why, as they are not children of the cockpit object. Anyway, I'll try that suggestion now

avatar image MajorParts · Sep 28, 2014 at 04:51 PM 0
Share

Cheers mate, look and not orbit it is :) I think when I started, that the mouse was controlling the ship and looked to the orbit, rather than altering the inputs. As to the other objects moving, I don't think they are, just that the ship doesn't pitch with the correct pivot. I will ponder that for a while before posting another numptyish question :) Thanks again!

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

Unity Android Movement Problem 0 Answers

weapon bob when looking 2 Answers

how to find mouse look 1 Answer

How can I produce the typical FPS mouse steering effect? 2 Answers

Age of empires Mouse and Camera controls (SOLVED) 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