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 /
This question was closed Jun 20, 2014 at 10:13 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Sares · Jun 20, 2014 at 03:23 PM · c#rotationquaternionjoystick

Joystick movement conversion to angle doesn't work anymore in C#

It worked perfectly in JavaScript:

 var newRot = Quaternion.LookRotation(Vector3(Input.GetAxis(xAxis), 0, Input.GetAxis(yAxis)));
 controller.transform.rotation = Quaternion.Lerp(controller.transform.rotation, newRot, Time.deltaTime*10);

Now in C# it doesn't work anymore:

 Quaternion newRot = Quaternion.LookRotation(Vector3(Input.GetAxis(xAxis), 0, Input.GetAxis(yAxis)));
 transform.rotation = Quaternion.Lerp(transform.rotation, newRot, Time.deltaTime*10);

LookRotation only wants a forward (optional an upward) parameter, strangely it worked in JavaScript. It controls the player character from a top down view with a locked camera angle.

Comment
Add comment · Show 3
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 meat5000 ♦ · Jun 20, 2014 at 02:21 PM 1
Share

One has 'controller.'

Does this have any bearing?

avatar image Sares · Jun 20, 2014 at 03:32 PM 0
Share

No, the error happens in the first line. It has no errors if I write Vector3.forward for example. I just don't know why it works in JavaScript.

avatar image meat5000 ♦ · Jun 20, 2014 at 03:36 PM 0
Share

Are xAxis and yAxis properly evaluating as Strings?

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Sares · Jun 20, 2014 at 08:33 PM

Yes they do. I wrote Vector3 instead of new Vector3... it's always the little things. Thank you anyway. That's the new working code:

 Vector3 input = new Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
 targetRotation = Quaternion.LookRotation(input);
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 meat5000 ♦ · Jun 20, 2014 at 09:50 PM 0
Share

Yep, that would've got me too :P

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Flip over an object (smooth transition) 3 Answers

Weird shake when I try to rotate player according to Virtual Cameras rotation. 0 Answers

How can i rotate a object more than once (90 degrees)? 1 Answer

Rotating a model with increments 1 Answer

ienumerator quaternion only rotating once 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