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 BDV · Feb 18, 2013 at 12:08 AM · camerarotationmovementeditorscene

Camera behavior the same as the unity editor has

Hi guys i want to create the same camera behavior as the scene view camera in unity.

moving with arrows on X/Z axis , rotating the camera just during holding the right mouse button and zooming with mouse wheel .. any ideas ?

The moving part is done ... it works perfectly , i tried just modify the MouseLook script with if (Input.GetMouseButtonDown(1)) but it doesnt work as i expected .

Comment
Add comment · Show 2
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 BDV · Feb 18, 2013 at 12:00 AM 0
Share

ok i fixed it with if (Input.Get$$anonymous$$ouseButtonDown(1)){ rightclicked = true; } if (Input.Get$$anonymous$$ouseButtonUp(1)){ rightclicked = false; }

it has only one problem ..

i am using this script to moving my camera

 public float speed = 10.0f;
  
 void  Update()
 {
     Vector3 movement = Vector3.zero;
  
     if (Input.Get$$anonymous$$ey("w"))
         movement.z++;
     if (Input.Get$$anonymous$$ey("s"))
         movement.z--;
     if (Input.Get$$anonymous$$ey("a"))
         movement.x--;
     if (Input.Get$$anonymous$$ey("d"))
         movement.x++;
  
     transform.Translate(movement * speed * Time.deltaTime, Space.World);
         
         
 } 

and the modified mouseLook script ... how can i fix the moving script to move according to rotation of the camera ?

avatar image Benproductions1 · Feb 18, 2013 at 03:14 AM 0
Share

Don't answer you own question with a comment, ins$$anonymous$$d edit your question.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by Benproductions1 · Feb 18, 2013 at 03:24 AM

Hello,

I'm not going to go over the scroll wheel, since even I don't know how that works in Unity... it changes some other camera stuff too. Also I'm not going to go over increasing speed using shift or just moving more. As you have already suceeded im making the mouse make the camera look, I'll just make it move :)

 function Update() {
     //Here you have the looking, whch you already have :)
     
     //First, lets check if left mouse is down
     if (Input.GetMouseButton(1)) {
         //Now lets move according to the direction
         //first forwards and backwards
         transform.position += transform.forward*Input.GetAxis("Vertical");
         
         //then sideways
         transform.position += transform.right*Input.GetAxis("Horizontal");
     }
 }

Hope this helps, Benproductions1

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 idbrii · Feb 20, 2018 at 05:08 PM

FlyCam_Extended shows how to implement movement and looking. It also shows moving faster/slower.

To limit movement to right mouse click, you can wrap the changes to transform.localRotation in transform.position with if (Input.GetMouseButton(1)) (as Benproductions1 showed).

Doing middle click panning would essentially be adding rotationX/Y to transform.position inside an if (Input.GetMouseButton(2)) block.

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

11 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

Related Questions

Changing master view move speed. 3 Answers

Relative Movement Problem 1 Answer

On can I have OnBecameVisible/Invisible ignore the scene/editor camera and only work for the game camera ? 6 Answers

Unity Scene View's right-click + WASD doesn't look 3D anymore? 2 Answers

On Network GameObject Movment and Rotation Problem. 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