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 CeejayZSmith · Dec 05, 2012 at 12:42 PM · javascriptcharacterrotatemoveplatformer

Help with plat-former character rotate

i have a modeled character and a move script with ground detection but i want to know how i could make a smooth turn for right to left and left to right when using the arrow keys thanks

Comment
Add comment · Show 2
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 BilboStabbins · Dec 05, 2012 at 06:00 PM 0
Share

I would take a look at the Unity '3D Platformer' demo project. I seem to remember is having this kind of turning rotation.

http://u3d.as/content/unity-technologies/3d-platformer-tutorial/3yF

avatar image Ben-Stoneman ♦♦ · Dec 06, 2012 at 02:49 PM 0
Share

Try creating a animation to manage the transition? The viewer will then find the turns much smoother.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CeejayZSmith · Dec 07, 2012 at 12:27 AM

ive done it guys if anyone whats to know what i did is i put 2 gameobjects on the ends or the map called rightTarget and leftTarget then i gave them this code:

 var player : GameObject;
 
 function Update () 
 {
 
  transform.position.y = player.transform.position.y;
 
 }


then i put in the character script if the button d is press transform.LookAt rightTarget and the same for the a button

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 BilboStabbins · Dec 07, 2012 at 12:45 AM 0
Share

That's.. original :)

Two things spring to $$anonymous$$d;

  1. The code above will snap the Player to the end of the map he's turning towards. Which means that every time he turns he will snap back to the LookAt target position.

  2. If you just used regular LookAt(), then that isn't smooth at all.

I would check out Ben's suggestion which is what I think is used in the link I gave.

Alternatively, if you want to use a smooth LookAt(), I would recommend a tutorial on Quaternions written by the guys here on Unity Answers. It can get quite advanced so best to learn the basics first.

Link: http://unitygems.com/quaternions-rotations-part-1-c/#Quaternions

Good Luck!

avatar image CeejayZSmith · Dec 07, 2012 at 01:39 PM 0
Share

would you say i should use Quaternion.Lerp? i have used Vector3.Lerp but im not an expert

avatar image BilboStabbins · Dec 10, 2012 at 04:20 PM 0
Share

Personally, for this purpose I wouldn't use any kind of LookAt but ins$$anonymous$$d go with the animation suggestion above.

I would learn the basics first, then worry about the icing on the cake like this kind of thing. Download the demo project, there's a lot you can learn from it in general. You might find you start co$$anonymous$$g up with your own ideas of how to achieve things.

However, to create a 'turn left' and 'turn right' animation for the Player, you can use Unity's Animation tool. You would just need to create a 180 deg turn for both directions, then play the appropriate one depending on which key you clicked.

Good Luck.

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

character controller rotation problem (c#) 0 Answers

Sprint Script Error?!!!! 4 Answers

counting seconds that character is idle. 1 Answer

how can i let my player move converse? 0 Answers

How can I tell Unity to wait to do something until after and animation has finished playing? 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