Math help in rotation

Hey all,

I am having trouble calculating the right math for this situation:

I have an array of spotlights where they can rotate in two forms:

1- base rotation

it goes from 0-360

then the spot-beam itself, going from -180 to 180

The array is a flat grid that can change dynamically.

I have for each spot their XID, ZID, Current point ID from the total array.
How do I calculate the base rotation+beam rotation, so all the spots point to the center? 0,0,0 ?

Thanks a lot in advance

The easiest way, is to make sure your component hierarchy is correct.

You need to have something you can rotate for each of these operations, just like real life.

Depending on the structure of the blueprint, this might actually be part of the model, but more typically, it would be additional scene components.

When you say, all pointing at 0,0,0 do you mean they should all point to the same location? Or should they all point in a grid, like your first picture?

you can use findlookatrotation() and then use the zaw on the base and the pitch on the beam. clamping as needed

With the base rotation + spot rotation, it’s possible to rotate each light in any direction needed, but I don’t know how to calculate the “Center aim” for all of them via blueprints.

I want that all the beams will point towards the same point (center point or actually any other point, but 0,0,0 would be a good start)

How can I use that assuming two rotation values? since I have one for the base, one for the beam - just like real life actually so I’m not sure how to calculate it

If you want them all to look at the same place, then ‘look at rotation’ is the way :wink:

That would work if the rotation would be one value,
but it’s 2 different ones for each object in the hierarchy.
With Look At Rotation on both of them, I get this:

Base is this axis:

And LightMoveManual is this one:

Base rotates on one axis 360 and LightMoveManual also rotates on only one axis.
Not sure how to combine two “look at rotation” in this case

Lost haha

1 Like

Much better picture :slight_smile:

The pivot of the base is causing problems.

Can you show the pivot of the light? ( click on the light )

you didnt break the rotation, you only want the zaw for the base and the pitch for the light. you may need to offset it depending on the default rotations but should work

tried your suggestion, looks interesting but not exactly right:


this is the pivot of “base”

and this if the pivot of “light”

Thanks so much as always :heart:

1 Like

the code is correct, is the base the root component? because if so see how the forward vector is pointing down not forward so that could mess things up.

I should have included the graph before, my bad, this is the scheme:


both anchor points are correct, same to how they work in real life.

So the pivot on the spot is good, the pivot on the base is not. You’ll need to put a scene component on the base to correct it ( because ‘look at’ always assumes X is pointing forward, and the base is using Z ).

Then you can use ‘look at’, but you’ll need to limit both of them to some axis only.

Bit busy now, but will come back soon :smiley:

1 Like

I tried but it’s a bit messy cause the main Viper module is rotated 90degrees down:

so I added a Scene object to reverse that, rotating it back, so the X is forward:

but then when I parent the rest to the new Scene object, oopsi:

so I think I made it worse haha

There’s a trick to doing it :slight_smile:

1 Like

So I made a ‘spotlight’ BP

image

You can see the base pivot is wrong.

So I put a scene in with X point in the world X direction

and now I can ‘hitch’ the base on that

Which means I can use the node to point the base in the correct direction.

I also hooked the light on the base

image

SL2

( works the same with relative rotation )

1 Like

■■■■ you’re good! works so nicely on your end

My issue is that my base model is already rotated:

so if I add a new “base” that is correct, it messes up all my model hierarchy and directions

maybe I can re-interoperate the output from the blueprint to match my pivots?

I tried to forcing all the pieces to look like yours, no luck


there are lots of ways to change the pivot but if you dont want to you can just ‘fake’ it, ie pitch is now roll so just test with different pins until it matches what you want

1 Like