Difference between revisions of "Rotating an object around another object with a script"
Rotating an object around another object with a script (edit)
Revision as of 21:58, 2 April 2007
, 21:58, 2 April 2007no edit summary
imported>JOG (oops, didn't want to remove "solutions"...) |
imported>Indefiance |
||
(2 intermediate revisions by the same user not shown) | |||
Line 48: | Line 48: | ||
; setting my own position | ; setting my own position | ||
[[set]] org_x to org_x + mod_x | [[set]] org_x to org_x + mod_x | ||
[[setPos]] X, org_x | [[setPos]] X, org_x | ||
[[set]] org_y to org_y + mod_y | [[set]] org_y to org_y + mod_y | ||
[[setPos]] Y, org_y | [[setPos]] Y, org_y | ||
Line 55: | Line 55: | ||
[[End]] | [[End]] | ||
[[Category: Solutions]] | |||
[[Category:Useful Code]] | |||
The following is in addition to the above with the effect that the object oscillates in and out, and up and down slowly dependant upon the values set in boolean, and zboolean. | |||
add these variables to the top of the script | |||
short boolean | |||
short zboolean | |||
and add this following code right after setting the mods, and before setting the players position (thats where I put it at least). The .2 value determines the speed at which the object oscillates on the mod_z and hdist dimensions, a larger value will cause the object to oscillate quickly, a smaller value subsequently means it will oscillate slowly. | |||
if mod_z > 390 + ( .06 * getRandomPercent ) | |||
set zboolean to 1 | |||
endif | |||
if mod_z < 290 + ( .06 * getRandomPercent ) | |||
set zboolean to 0 | |||
endif | |||
if zboolean == 0 | |||
set mod_z to mod_z + .2 | |||
endif | |||
if zboolean == 1 | |||
set mod_z to mod_z - .2 | |||
endif | |||
if hdist > 350 + ( .06 * getRandomPercent ) | |||
set boolean to 1 | |||
endif | |||
if hdist < 250 - ( .06 * getRandomPercent ) | |||
set boolean to 0 | |||
endif | |||
if boolean == 0 | |||
set hdist to hdist + .2 | |||
endif | |||
if boolean == 1 | |||
set hdist to hdist - .2 | |||
endif | |||
[[Category: Solutions]] | [[Category: Solutions]] | ||
[[Category:Useful Code]] | [[Category:Useful Code]] |