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 OmniverseProductions · Apr 22, 2012 at 02:50 AM · gridkeypressrotating

Rotating on key press and strafing for the fps camera

I'm using a grid movement system and I'm trying to figure out how to rotate my first person character with a key press and have him strafe or sidestep left and right. The character moves and rotates, but that's together. I want the character to rotate separately. I should probably say that I'm using the js version of the GridMove script Eric5h5 created. I could probably use the C# version considering the character doesn't rotate in that script. Which ever one is easier for you to help me on.

Edit: I got it with the following code but it turns way to fast. How do I slow it down. Also I forgot to say that I need it to rotate in 90 degree angles.

 if (Input.GetKey(KeyCode.E)) transform.Rotate(0, 90, 0);

 if (Input.GetKey(KeyCode.Q)) transform.Rotate(0, -90, 0);
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
1
Best Answer

Answer by AchillesWF · Apr 22, 2012 at 03:36 AM

If you want to slow it down you'll need to do the rotation in more than just a single frame as you are currently doing. Rotate in the direction you want, using a function like Slerp() to control how much of the rotation is actually performed during a single frame. You can set a target rotation, then in each update call if you are not at your target rotation, rotate a little bit more towards the target, clamping your rotation when you get there.

Comment
Add comment · Show 1 · 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 OmniverseProductions · Apr 22, 2012 at 04:02 AM 0
Share

I completely looked past that. Thank you. It works perfectly.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to not go below the grid in scene view 1 Answer

Issues with manual collision detection involving updates... 1 Answer

Chunks and 2d Hex-grid Generation 0 Answers

Windows Server 2012 with NVIDIA GRID GPU 0 Answers

Rounding Errors when snapping to grid 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