Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
StarvinMarvin

How do i make an object fly in circles around another object?

Recommended Posts

Silly thing i wanna do to fool my teammates a bit. wanna create a white flare flying randomly around the chopper/plane when we go out to the missionarea together with the main theme from the xfiles :P can this be done and how do i do this?

Thanks

//Marv

Share this post


Link to post
Share on other sites

Well assuming you know how to place a flare in a given position, I can help with the math to figure out where to place it. STUFF_IN_CAPS should be replaced by numbers (or defined by #define SOMETHING_IN_CAPS <number>).

_rx = RADIUS_X;
_ry = RADIUS_Y;
_rz = RADIUS_Z;
// _ry = _rx will result in a circle, else will result in an ellipse
// _rz is how much it will go up and down (0 will make it stay leveled with the helo)

_w = ROTATE_SPEED_IN_RADIANS_PER_SEC
_wv = UP_DOWN_SPEED_IN_RADIANS_PER_SEC
// _w = [b]360 [/b]will result in 1 turn per second
// _wv will make it go up and down as well relative to the chopper. Will probably look better if you make it so that _wv>=_w, as too rapid movement on the z axis probably won't look good.

bContinue=true;
while {bContinue} do
{
  _x = getPos helo select 0 + _rx * sin (_w * time);
  _y = getPos helo select 1 + _ry * cos (_w * time);
  _z = getPos helo select 2 + _rz * sin (_wv * time);
  // add whatever you do to move the flare to [_x,_y,_z]
  sleep .001;
  // you can sleep longer but then it won't be smooth. should be fine with sleeping .001 since it will always sleep at least until the next frame anyway, which is exactly what you need for smooth movement.
};
// once you want it to be over, set bContinue to false (via trigger or something), delete the flare and/or do whatever

Edited by galzohar
corrected since angles in the game are in degrees, not radians.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×