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 Koboh Z · Nov 11, 2010 at 01:03 AM · cameramovementcontrol

controls like old game

I want to make a camera and character movement control set up that works like this:

  • W to walk forward.
  • A to rotate camera to the left.
  • D to rotate camera to the right.
  • S to walk back.
  • Mouse to look up and down or tilt the camera.

I have some code that does everything but the turning the camera to the left and right when I press the A or D key, instead the player [incorrectly] moves in that direction.

Here is the code I'm working with. I know it has something to do with rotate, transform and get key. Anyone that can point me in the right direction?

private var fpcMouse; private var camMouse;

function Start () {

 fpcMouse = gameObject.Find("Player").GetComponent("MouseLook");
 camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");

}

function Update () { if (Input.GetKeyDown(KeyCode.Q)) {

     Screen.showCursor = !Screen.showCursor;
     Screen.showCursor = true;
     fpcMouse.enabled = !fpcMouse.enabled;
     camMouse.enabled = !camMouse.enabled;
 }

}

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

Answer by fireDude67 · Nov 11, 2010 at 01:28 AM

Have you tried the FPSController yet?

Also you can attach a camera component to your character and do something like:

transform.Rotate(0, Input.GetAxis("Horizontal"), 0);

However this will rotate the character using both A/D and left arrow/right arrow. You can change this using the input manager

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 Koboh Z · Nov 11, 2010 at 06:34 AM 0
Share

yes but the FPSController moves the camera with the mouse in all directions and all i want is to tilt with the mouse I will take another look at it maybe I can modify it thanks

avatar image fireDude67 · Nov 11, 2010 at 10:33 PM 0
Share

ok i added some different code

avatar image Koboh Z · Nov 11, 2010 at 11:02 PM 0
Share

sweet thanks I will check it out some time this weekend its wife time today so no unity for me lol

avatar image fireDude67 · Dec 29, 2010 at 05:50 PM 0
Share

if you use FPSController, then remove the $$anonymous$$ouseLook script on the First Person Controller gameObject, then add a script to it like the one above

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

No one has followed this question yet.

Related Questions

How to make camera position relative to a specific target. 1 Answer

Make camera follow cylindrical track 1 Answer

Move RigidBody character relative to camera. 2 Answers

AddForce to Camera 1 Answer

RTS Camera Rotation and Movement 0 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