• 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 HunterTank95 · Apr 05, 2014 at 10:51 PM · rotation axis

Cannot get Plane to Rotate while facing camera

Below is the code that I have been using:

using UnityEngine; using System.Collections;

public class discRotate : MonoBehaviour {

 public float rotationSpeed;
 private Vector3 euler;

 // Use this for initialization
 void Start () 
 {
     rotationSpeed = 60;
     euler = transform.eulerAngles;
 }
 
 // Update is called once per frame
 void Update () 
 {
     //rotate mathematically about axis:
     euler.z = ( euler.z + rotationSpeed * Time.deltaTime ) % 360;
     //update object rotation:
     //transform.EulerAngles = euler;
     transform.localEulerAngles = euler;
 }

}

No matter what axis I try the plane will always rotate in a direction that brings it in and out of visibility. Rotating along the Y-axis (this axis is pointed straight at the camera) should give me what I am looking for but changing that value is the same as changing the Z-axis when I run it.

HELP!

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 sixEight · Apr 06, 2014 at 12:08 AM 0
Share

When changing it to the following, like you said:

 euler.y = ( euler.y + rotationSpeed * Time.deltaTime ) % 360;

The plane rotates in front of the camera for me.

avatar image HunterTank95 · Apr 12, 2014 at 09:04 PM 0
Share

problem was with Unity not refreshing my code. Thanks!

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by HunterTank95 · Jun 01, 2015 at 09:43 PM

solved my own problem but thanks sixEight for the help!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

How can I stabilize a vehicle's roll during a jump using forces? 1 Answer

how can i make an object rotate on the scenes axis 0 Answers

How to Rotate a game object towards the mouse click 3 Answers

Child object rotation axis problem (Unity 5) 0 Answers

Rotation via script behaves unexpectedly 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