Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with lookAt function and X rotation

New Here ,
Mar 19, 2022 Mar 19, 2022

Hello,

I use the lookAt function to orient a text layer to a NULL layer position but I want to be able to rotate the text layer on the X axis too.

 

To look at the NULL layer correctly, I need to set the Y rotation to 270°

I think the problem is here, if I want to rotate on the X axis correctly, the Y rotation must be 0 or 180/-180.

 

I think that I need an expression to recalculate the Y and Z orientation with the X orientation set to 0.

And maybe an expression to set Y rotation value too.

 [ VIDEO ] 

 

Thanks in advance for any help!

TOPICS
Expressions
587
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 19, 2022 Mar 19, 2022

Would it help to put the lookAt() expression on a 3D null and parent the text layer to that, so you could adjust the text layer's rotation independently?

Translate
Community Expert ,
Mar 19, 2022 Mar 19, 2022

Would it help to put the lookAt() expression on a 3D null and parent the text layer to that, so you could adjust the text layer's rotation independently?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 19, 2022 Mar 19, 2022

Yes Dan, thank you it's exactly what I want to do.

But is there a way to calculate the orientation?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2022 Mar 19, 2022

Probably, but unless it's trivial (which this may be, I don't know) things can get out of hand pretty quickly when you have to do 3D rotation matrix math...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 19, 2022 Mar 19, 2022

http://www.motionscript.com/design-guide/auto-orient-y-only.html

 

Can easily be modified to work for a different axis. That and of course there's a ton of other "targeting" expressions out there that could be used as well.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 19, 2022 Mar 19, 2022

Thanks Mylenium,

The expression returns an angle

delta = toWorld(anchorPoint) - thisComp.activeCamera.toWorld([0,0,0]);
radiansToDegrees(Math.atan2(delta[0],delta[2]))

but I need to convert the original orientation from [X, Y, Z] to [0, Y, Z]

I tried to add or substract the angle but it doesn't work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 19, 2022 Mar 19, 2022
LATEST

Finaly, don't need to calculate the new orientation using Dan's trick, then 

just need to unparent or delete the new NULL layer to get the correct orientation.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines