ParentRotationChangesRotation
Introduction
The ParentRotationChangesRotation property tells an object whether its rotation should be relative to its parent rotation. This is true by default but it can be set to false.
Sample Code
This code could be used to tell a health bar to not rotate when whatever it is attached to rotates:
ParentRotationChangesRotation
Attachments create a relationship in which the child is both positioned and rotated relative to the parent. In some cases it is useful to suppress some of this behavior.
The ParentRotationChangesRotation property controls whether the rotation of a child is modified by the parents' rotation. In the following example the ship Sprite (represented by the red ball) rotates and moves according to input from the keyboard. The Camera is attached to the Sprite but does not rotate with it.
Declare the ship at class scope:
In Initialize:
In Update:
Notice that although the Camera is attached to the ship Sprite, it does not rotate. Try setting the Camera's ParentRotationChangesRotation property to true and observe the behavior.
Last updated