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
1
Question by Matthew Scott · Dec 08, 2013 at 10:05 PM · rotationparticlesbillboardclouds

Cloud System Billboard (Look At) Script Z axis lock?

So I've managed to create a cloud system which prodecurally generates cloud particles and volumetric cloud shapes, and it's working great. I'm using my own custom made particle system but I'm having some trouble getting the billboard code to work exactly how I want...

alt text

On first impression everything seems to work fine, the billboards are set to always face the camera direction. BUT, the problem is:

  • When you fly over the top of the cloud looking down, the particles spin around the z/forward axis making it look like there's some sort of tornado going on, completely ruining the illusion of my pretty cloud ='[

I would like to find a solution that allows the billboard to face the camera along its z axis without causing the irritating z rotations. I've tried the following solutions so far with no luck;

Where childT is the transform of each cloud particle...

 //Method 1
 childT.LookAt(Camera.main.transform.position);
 //Causes Z axis swirling

 //Method 2
 childT.LookAt(Vector3(childT.transform.position.x, childT.transform.position.y, Camera.main.transform.position.z));
 //Causes slicing (looking straight down billboard) and incorrect Y rotations

 //Method 3
 childT.LookAt(Camera.main.transform.position);
 childT.eulerAngles.z = 0;
 //Same as Method 1
 
 //Method 4
 childT.rotation = Quaternion.LookRotation(new Vector3(Camera.main.transform.position.x, 0, Camera.main.transform.position.z) - new Vector3(childT.position.x, 0, childT.position.z));
 //Causes swirling on the Y axis (rotating slices)
         
 //Method 5
 var point : Vector3 = Camera.main.transform.position;
 point.y = 0.0;
 childT.LookAt(point);
 //Same as Method 1

Is this a gimbal lock thing?

Nothing seems to be working, all I want it to do is look at the camera and keep it's original rotation around the z axis...even if that means the particle is technically upside down if you've completely gone over the top of it...whose gonna know, it's a cloud puff...

Can't have this swirling nonsense! >.> Getting me doooowwwn.

Would greatly appreciate any help from rotational mathy expert types =P

I'm also open to any solution that involves the shader taking care of the rotation via realigning the vertices of the geometry via screen space or something...maybe?

[2]: /storage/temp/19088-cloudzswirl.jpg

cloud.jpg (48.0 kB)
Comment
Add comment · Show 1
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 Matthew Scott · Dec 08, 2013 at 10:23 PM 0
Share

Also tried this:

 var distance : Vector3 = Camera.main.transform.position - childT.position;  
 var rot : Quaternion = Quaternion.LookRotation(distance);
 childT.rotation = rot;
 childT.eulerAngles = Vector3(childT.eulerAngles.x, childT.eulerAngles.y, childT.eulerAngles.z); 

I've been placing "0" in the x, y, z values of the last Vector3 in childT.eulerAngles in different combinations but nothing helps...

However, even though it doesnt work properly, setting the Y to zero and looking at the behavior makes me think that this whole swirling thing has something to do with the Y axis?

1 Reply

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

Answer by Matthew Scott · Dec 09, 2013 at 05:23 AM

childT.LookAt(Camera.main.transform.position, Camera.main.transform.up);

Sorted. Sometimes it's just that simple ._.

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.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Billboard along single axis maintain control over x and z axes 0 Answers

Billboard Particles Orienting to User in VR 1 Answer

alphablended shader rendering infront of billboarding trees? 1 Answer

What's a simple way to have realistic, moving clouds? 4 Answers

How do I use TRS matrices in the GL class in loops without it being reset? 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