Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by UNBLVERS · Sep 29, 2016 at 12:37 PM · rotationmovementscript.

How to make a turn like the Temple Run and NO THING ?

Now I create a game like the Temple Run and NO THING(store.steampowered.com/app/444800/) .

But I don't know to create a turn motion like the Temple Run to player. For example, press a key to turn left, d key to turn right.

Please help me:/

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 Robert_s_a · Mar 14, 2017 at 05:21 AM

@UNBLVERS

I've never played Temple Run, but from your question, I think this is what you are looking for...

Unless you've changed it from the default settings, there is a Input.GetAxis("Horizontal") command which will read the A and D keys (also the left and right arrow keys) and return a positive number for D and right arrow, or a negative number for A and left arrow. You can use this to apply a rotation to your player.

There's also a Input.GetAxis("Vertical") function which reads the W and S, and up arrow and down arrow keys, which is often used for moving forward and backward - I'll leave that for you to play with.

The rotation part can be done something like this...

 private float rotation;
 private float rotationInput;
 private float rotationSensitivity = 10.0f;    // Adjust how quickly the player turns
 private Quaternion rotationAngle;             // This is what Unity uses to handle rotation

 private Update()
 {
     // read keyboard input for horizontal axis
     rotationInput = Input.GetAxis("Horizontal");

     // adjust it based on the required sensitivity
     rotation = rotationInput * rotationSensitivity;              

     // Convert the value to a rotational angle
     rotationAngle = Quaternion.Euler(0.0f, rotation, 0.0f);

     // Apply the rotation to your player object
     transform.rotation = rotationAngle;                                   
 }

Depending on how you have your player set up, you may need to make the rotationSensitivity a negative number if you find that the player is turning the wrong direction.

I hope this helps.

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 Nehrk · Mar 14, 2017 at 08:01 AM

See this. link Using DOTween path and other plugins can help you make this much faster.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

moving an object continuously between waypoints 0 Answers

How to return original rotation of object 0 Answers

Record and replay movement 0 Answers

How do I move a prefab the same speed as my scrolling background? 0 Answers

Look Left or right but keep walking forward 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