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 Jordi · May 26, 2012 at 01:51 PM · cameradirectiondistance

Camera position

This must have been asked a thousand times, as it's pretty basic. But I'm not able to grasp it. So I'm trying a seemingly simple control scheme here. The player uses a joypad, with the left analog stick the character moves forward/backward and sidesteps. The right analog stick is supposed to rotate the camera + character along the character's up direction, and moving the analog stick upwards rotates the camera along the right axis of the character. I've been trying to create a system that saves the direction of the camera and the distance to the player, but I can't make it seem to work. How would I best go about this?

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 Berenger · May 26, 2012 at 03:31 PM

Import the Character Controller package and take a look at the MouseLook script. You will need to adapt it a bit to replace the mouse input by the analog stick input, but otherwise it's seems similar.

Then, attach that script to the player and parent the camera to him.

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 Jordi · May 27, 2012 at 11:44 AM 0
Share

Thanks! I've been looking at it and just one thing is foreign to me: at the top is a property called 'enum' and I'm not entirely sure what this does?

avatar image Berenger · May 29, 2012 at 03:42 PM 0
Share

enum is, I'd say a Type, but anyway it associate a name to an int. It can be use to have more option than a boolean. Here is an example :

// Those two lines are identical, I wrote both to point out what's going on public enum AI$$anonymous$$ode{ Enemy = 0, Ally = 1, Neutral = 2 } //public enum AI$$anonymous$$ode{ Enemy, Ally, Neutral }

// This can be modified in the inspector // As you'll see the name, it's much easier to remember what does what. // $$anonymous$$eyCode is an enum, imagine if we had to remember that 46 is Escape etc. public AI$$anonymous$$ode mode; public void OnTriggerEnter(){ if( mode == AI$$anonymous$$ode.Enemy ) // Enemy stuff else if( mode == AI$$anonymous$$ode.Ally ) // Ally stuff else if( mode == AI$$anonymous$$ode.Neutral ) // Neutral stuff }

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Move character in direction its facing 1 Answer

find a world-space coordinate from ScreenPointToRay(Input.mousePosition) raycast 2 Answers

Not shooting in desired direction 1 Answer

RTS camera help 1 Answer

Calculate vector3 from angle 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