Consecutive RotateAround usage

Hello,

I have a wind turbine consisting of three blades, a nacelle (turbine housing), and the tower. I want to have the blades rotating about the forward axis (to simulate spinning during wind). I also want the nacelle (with blades attached) to spin about the up axis (to simulate the turbine turning to catch the wind from different directions). I can simulate the blade rotation just fine. The problem lies with rotating the nacelle and blades together. The blades no longer will spin on the desired axis, but start tilting at odd angles. What am I doing wrong?

// Update is called once per frame
    void Update () 
    {   
        Time.timeScale = windSpeed;

        this.transform.RotateAround( test.transform.position, Vector3.forward, windSpeed * Time.deltaTime );
        this.transform.RotateAround( test.transform.position, Vector3.up, windSpeed * Time.deltaTime );
    }

So, I've found the problem lies in consecutive calling the RotateAround function. If I comment out just one of the lines, the rotation works perfectly, but if they are both together, I get odd rotations. Any ideas how to fix this?

Hi,

You need to organize your models into a hierarchy so that the blades are childs of the nacelle. Then you use transform.rotate() instead which will by default rotate around itself no matter how it is oriented in the world. You'll also need to split your component into two. One for the blades, one for the nacelle. This is bonus because you then can implement all the specialty without cluttering one single script.

Also from your example, I think you get the wrong rotation for the nacelle as the nacelle needs to orient itself in the opposite direction of the wind, while the blades do rotate using the windSpeed variable.

Hope it makes sense. Else, if you can share a sample project, I'll happily modify it so that it works.

Bye,

Jean

The problem is that you're rotating the blades around the global z axis (Vector3.forward). But you want to rotate it around their forward axis - if that makes any sense to you. Use the blades' transform.rotation.forward as opposed to Vector3.forward and everything should work. It is of course important that the blades are parented to the nacelle, so that when you rotate the nacelle about the y axis the blades will follow the motion. Note that for the nacelle it's fine to use Vector3.up because it will always be facing globally up. If it is angled however (at a hillside, for instance) it would be important to use it's local up axis and not the global one.

Good luck!

Hi,

i’m having a similar problem: these two consecutive rotateAround calls give me unwanted rotation in Z axis:

	transform.RotateAround (objetivo.position, objetivo.transform.right, input_eje_y);
	transform.RotateAround (objetivo.position, objetivo.transform.up, input_eje_x);

if I comment out any of them, i only get rotation around the proper axis. Any clue??

Thanks in advance!