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 Dino97 · Sep 18, 2010 at 12:09 AM · cameracharacterrotate

character and Camera rotate

hi all,i need help....im making rpg game and i don't know how to make something....When i press A or D my character going to left,what i need to do to make my character (with camera) rotate when i press A or D...

Example: Press A - My character and camera rotate in left like in world of warcraft when i rotate my camera my character automaticaly rotate with camera or when press a or d in wow my character and camera moves

sorry for bad english

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Paulius-Liekis · Sep 20, 2010 at 07:57 AM

You can either parent your camera to character (or vice versa) to make it attached, or you can update camera position from script based on character's position.

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 Mike Roam · Mar 25, 2011 at 03:12 PM

After a few hours of messing around with various scripting suggestions, I got this working for controlling a simple cube.

I learned the hard way that integer math can destroy Time.deltaTime, and that editing a script does NOT change the copy of the script that is attached to a character.

// I called this script move.js and added it to my main character.

var sspeed = 5.0; // speed that the var turnSpeed : float = 90.0; // degrees per second. //Good to have ".0" or explicit "float" because int math kills the turning!!

function Update () { // Move Forward or Backward... // [default keys: w/s/fwd/bak = "Vertical" (z axis)] var z = Input.GetAxis("Vertical") Time.deltaTime sspeed; transform.Translate(0, 0, z);

 // Turn Left or Right...  
     // [default keys: a/d/left/right = "Horizontal" (x axis)]
     // beware: MUST do the math with explicit floats to avoid int round off!
     var turnAngle : float = turnSpeed * Input.GetAxis("Horizontal") * Time.deltaTime;
 transform.Rotate (0, turnAngle, 0);

} // Update( )

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

No one has followed this question yet.

Related Questions

Sidescroller Turning 1 Answer

MMORPG Rotate Character 1 Answer

Rotate camera to character angle 0 Answers

Turning torso of character with mouse 0 Answers

Clamping the Camera, according to the player ? 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