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 Cleger · Aug 21, 2012 at 08:48 PM · quaternionbillboard

Trouble making Dynamic Billboard

I'm a long time trying to make a dynamic billboard script. I need to control the different axes billboard blocking do not want to be billboard but not equaling zero, but retain the original rotation of that axis. I searched many forums without finding an answer. I have studied the Quaternion system, and I managed to handle it but only on one axis and not two, and always having to carry zero axes do not want to be modified. There is some information that I'm driving or something I'm doing wrong.

I hope someone can help me, thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Aug 21, 2012 at 08:50 PM

using UnityEngine;
using System.Collections;
public class BillboardOrienter : MonoBehaviour {
    public Transform target;
    private Vector3 myUpDirection;
    void Start() {
        myUpDirecton = transform.up;
    }
    void Update() {
        Vector3 relativePos = optionalTarget.position - transform.position;
        Quaternion rotation = Quaternion.LookRotation(relativePos, myUpDirecton);
        transform.rotation = rotation;
    }
}
Comment
Add comment · Show 6 · 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 Cleger · Aug 21, 2012 at 09:08 PM 0
Share

Scroodge, thank you for your quick response. The reply code already knew, what I need is to make a two-axis rotation. For example the x and y axis look at the camera and keep your angle z axis.

avatar image ScroodgeM · Aug 21, 2012 at 09:36 PM 0
Share

X and Y axis look at the camera? i can't imagine it 8) please explain 8)

avatar image Cleger · Aug 22, 2012 at 06:47 AM 0
Share

Sorry, you're right, what I meant is that for example the z axis is facing the camera, the angles X and Y rotate but the angle z is fixed at a certain angle. thanks

avatar image ScroodgeM · Aug 23, 2012 at 10:32 PM 0
Share

second parameter in Quaternion.LookRotation method is created to point the 'up' direction. this lets you keep Y-axis on rotated object to be as close as possible to 'up' using rotating around Z-axis. methinks this is what you need.

avatar image Cleger · Aug 24, 2012 at 01:36 AM 0
Share
 var relativePos=optionalTarget.position-transform.position;
 transform.rotation=Quaternion.LookRotation(relativePos,Vector3.forward);

is the closest thing I need but the Z axis is fixed at zero. If the object has an original rotation on the z axis, when I applied the script modifies the z axis rotation and makes it as if the angle is zero.

Show more comments

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

8 People are following this question.

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

Related Questions

Use Iphone as sterring wheel 2 Answers

Billboard script 1 Answer

Can you help me sort out my script and collision? 1 Answer

How to set rotation.y to predefined angles. 3 Answers

Third Person Camera Orbit 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