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 Rasa · May 06, 2014 at 06:34 AM · c#rotatecamera-movement

Rotate camera smoothly for particular position with single INPUT

  • I'm trying to rotate the Main camera which is child of the character.

  • And I have to rotate that with single Input which means single press of left or right Arrow Key.

  • Character may in XXX angle and have to rotate the Main camera left and right of the character 45 degree

But I did this through continuous pressing of left and right arrow keys in C#... Now I'm trying this with single press it have to rotate smoothly for particular angle.

This is normal image in some angle alt text

Like this, I have to rotate camera smoothly for particular angle with single press of left and right Arrow key. alt text

This is getting too late to finish...so lets see which adroit will answer for this...thanks ..

normal.jpg (84.9 kB)
left and right.jpg (148.4 kB)
Comment
Add comment · Show 11
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 Swaggre · May 06, 2014 at 08:22 AM 0
Share

add a bool, when you press the key make the boolean true. when the boolean is true the camera lerps to the right place.

avatar image Rasa · May 06, 2014 at 10:06 AM 0
Share

Finally I got Code In Js but I need this in C#....! private var qTo = Quaternion.identity;

 function Update () {

   if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.A)) {
     rotation += 45.0;
     qTo = Quaternion.Euler(0.0,rotation,0.0);

   }
   if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.S)) {
     rotation -= 45;
    qTo = Quaternion.Euler(0.0, rotation,0.0);
   }
 
   transform.rotation = Quaternion.RotateTowards(transform.rotation, qTo, speed * Time.deltaTime);

     Is there any one to convert this in C#. . . !

I did, but rising Errors. . .

  private Quaternion qTo = Quaternion.identity;
  .
  .
  .
avatar image thornekey · May 06, 2014 at 10:11 AM 0
Share

public GameObject qTo;

 void  Update () {
  
   if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.A)) {
     rotation += 45.0f;
     qTo = Quaternion.Euler(0.0f,rotation,0.0f);
  
   }
   if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.S)) {
     rotation -= 45;
    qTo = Quaternion.Euler(0.0f, rotation,0.0f);
   }
 }

C# :)

avatar image Rasa · May 06, 2014 at 10:18 AM 0
Share

I did same as this but raises error... :-(

  • The best overloaded method match for UnityEngine.Quaternion.Euler(float, float, float)' has some invalid arguments - Argument #1' cannot convert double' expression to type float' These both errors are in qTo line only...

avatar image thornekey · May 06, 2014 at 10:23 AM 0
Share

rotation is not a float thats why.. where have u declared the rotation variable? put this at the top

public float rotation = 0.0f;

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Turning Spinners Based on an Integer 0 Answers

Unity 3d(Space) Questions 1 Answer

How do I rotate a Rigidbody to a surface normal AND use camera rotation? 1 Answer

Multiple Cars not working 1 Answer

C# how to rotate an object back to its original rotation 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