I am working on a project that has solar panels. The solar panels must always face the sun in the most efficient way.
In my test project, there is a sphere (representing the sun), rotating around the center of the world.
This is my solar panel placed vertically:
This is the blueprint part to make the solar panel face the sun:
The solar panel rotates around its z-axis to always face the sun (the orange sphere is the sun). It works like a charm:
The problem starts when I have a solar panel, which is placed with an angle other than 90 degrees. This is my solar panel;
When I start it with the same blueprints, it makes it vertical because Roll and Pitch are 0. If I try to set the Roll and Pitch like this:
It makes it rotate around the world’s z-axis.
This is something I don’t want.
I want it to rotate around its local z-axis. I think the only way to do it is to use an “Add Local Rotation” node. When I add local rotation only to the z-axis, it behaves like I want (rotating around its base), but I can’t calculate what value to enter the add local rotation’s z input.
I need help in calculating the local angle, using the sun’s world location and the solar panel’s world rotation or forward vector (also not sure about this).
Any help would be appreciated.