Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 oliver-jones · Dec 09, 2010 at 09:08 PM · rotationcamera-movementverticalhorizontal

Possible To Add Move Functions To Camera?

Hello,

I have a Orthographic camera in my scene, right now, all it does (movement wise) is zoom in and out via the scroll wheel.

Is it possible to add Left, Right, Up, Down functions to the camera too? Maybe even rotation? (< and > keys for rotation?)

I do not want to control the camera movement with the mouse (unless the mouse moves towards the edge of the screen - thus causing the camera to move in that direction -- but this isn't important right now)

Point in the right direction?

Cheers

Comment
Add comment · Show 3
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 Justin Warner · Dec 09, 2010 at 10:07 PM 0
Share

So would you want it to be like, arrow keys/WASD to move the camera?

If so, couldn't you add FPS Walker script to the camera, then you can move the camera around, and then you can take out the jump script and all that, so it just moves around wen you push the keys... Does that work or not quiet? (BTW, your TD game looks fun =) )

avatar image JesusChristChangedMe · Dec 11, 2010 at 12:59 PM 0
Share

I think he wants it so that the camera doesn't have gravity.

avatar image oliver-jones · Dec 11, 2010 at 01:38 PM 0
Share

I literally just want it so when I press A the camera will move left, or D then the camera will move right. Thanks

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by oliver-jones · Dec 11, 2010 at 01:50 PM

Figured it out, quite simple really:

transform.Translate(0, Input.GetAxis ("Vertical") * rotateSpeed, 0);
transform.Translate(Input.GetAxis ("Horizontal") * rotateSpeed, 0, 0);

Thanks anyway.

Comment
Add comment · Show 2 · 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 JesusChristChangedMe · Dec 11, 2010 at 05:18 PM 0
Share

Glad you figured it out!

avatar image Jesus_Freak · Dec 12, 2010 at 02:49 PM 0
Share

that's kind of what i'm doing, O.J., but i just have it automatically moving the cam with the Translate function, but that's smart to use inputs.... very smart! 1+

avatar image
0

Answer by JesusChristChangedMe · Dec 09, 2010 at 09:15 PM

Try this script.

    var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
    {
        var controller : CharacterController = GetComponent(CharacterController);
        transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
        var forward = transform.TransformDirection(Vector3.forward);
        var curSpeed = speed * Input.GetAxis ("Vertical");
        controller.SimpleMove(forward * curSpeed);
    }
@script RequireComponent(CharacterController)
Comment
Add comment · Show 3 · 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 oliver-jones · Dec 09, 2010 at 09:20 PM 0
Share

Nearly - Two problems though. First one being that it falls (as if it has a rigidbody : gravity) towards the terrain. And the movement is more of a tilt, rather than a move left/right.

avatar image JesusChristChangedMe · Dec 10, 2010 at 09:50 PM 0
Share

Remove the @script RequireComponent(charactercontroller) and that should do it

avatar image oliver-jones · Dec 11, 2010 at 01:41 PM 0
Share

Tried it - but its still 'rotating' the camera, rather than moving the position. W and S don't even do anything?

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

Limit rotation (Horizontal and vertical input) 1 Answer

get euler rotation from horizontal and vertical axis values 1 Answer

Simple controls for a helicopter 2 Answers

Rotating horizontally around a sphere 1 Answer

How can I play different animations depending on the direction my character is moving? 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