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 SuIXo3 · May 15, 2012 at 12:34 PM · camerartsbehaviourwasd

Free Camera

Hi, I'm trying to create a free camera to travel around the map, like RTS games. More precisely like the World in Conflict camera. WASD to move on XY, scroll wheel for Z, and middle mouse button for rotating around (like a head, on camera pivot).

I can get the camera moving with WASD and turn around with the mouse, but it turns as soon as I click play, not only when RMB is pressed.

And another problem I don't know how to resolve is the movement vector is always the same, not depending on where you look. If you look to the right from the original position, W still send you straight, not to the right (where you are looking).
So the vector should depend on the camera angle. How do I program that?

I hope I explained myself enought, any help is welcome, on already made things or tips to make it.

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 Kith · May 15, 2012 at 01:40 PM 0
Share

In order to help you, we're going to need to see some code I'm afraid.

avatar image Berenger · May 15, 2012 at 02:12 PM 0
Share

Basically, you need to tweak the $$anonymous$$ouse Look script from the FPS char controller. You need to add a translate along the camera's axis for WASD and a control of the fov for the wheel.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Befall · May 16, 2012 at 08:47 PM

Simple trig should help you out immensely here.

I didn't something similar for a work project, and the easiest thing to do is to grab a cross product with a vector local to the camera.

So, if you wanted to move forward, to get the forward vector, assuming the camera is at an angle, you'd have to do Vector3.Cross(Vector3.up, camera.transform.right) for forward/back and camera.transform.right for left/right, just using the negative to go the opposite way.

Also meant to mention that this should work with any rotation along Vector3.up and camera.transform.right, because the vector going to the camera's right will always be correct, and Vector3.up will always be the up vector you need for the cross product.

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 SuIXo3 · May 22, 2012 at 07:02 PM

I managed to get it done. I used vector3 like you said. Thx. Then I just limited the height equaling Y at the same value all the time. Changing based on mouse wheel

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Attaching an RTS scrolling script to a camera (Noob Question) 3 Answers

Camera rapidly changes it's position when the parent changes. 0 Answers

Third Person Camera Orbit 0 Answers

move camera to clicked object 0 Answers

Smooth camera height adjustment based on terrain 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