In a platform activity, you can make a monster circle around a collectable item, making it difficult for a character to collect the item.
Within a platform activity select the top "apple" and then select a "monster" and place it on the apple. Right click on the monster, then click on the green rotation arrow below the image to view the animation options that are attached to the monster. Click on the red fish (for animation settings) and click on the "adv" option. in the script box that appears, enter the following code;
var angle = Math.atan2(this._y - _root.s13._y, this._x - _root.s13._x) + 0.05;
this._x = _root.s13._x + Math.cos(angle)*100;
this._y = _root.s13._y + Math.sin(angle)*100;
Explanation: You need to understand trigonometry for this one! The first step works out the angle between the 2 objects by taking the arctan of the difference in y over the difference in x. The 0.05 adds slightly to the angle which results in the orbit effect. The next two lines calculate the x and y position of the monster by starting off from the apple's position and taking the cos or sin of the angle, multiplied by the radius of the orbiting circle (in this case 100).
View example, Download Orbiting_monster


Recent Comments