Home   Help Search Login Register  

Author Topic: Rotate object around another one [SOLVED]  (Read 1036 times)

0 Members and 1 Guest are viewing this topic.

Offline Deadfast

  • Members
  • *
Rotate object around another one [SOLVED]
« on: 12 Feb 2009, 21:43:53 »
Hello fellow scripters,
I'm struggling with a little problem here.


Basically what I need is to have an object (red) rotating around another, static one (yellow).


Unfortunately for me my math sucks too much to be able to figure this on my own  :confused:.



Thanks in advance,
Deadfast
« Last Edit: 12 Feb 2009, 22:23:47 by Deadfast »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Rotate objects around another one
« Reply #1 on: 12 Feb 2009, 22:09:49 »
Code: [Select]
_yellow = _this select 0;
_red = _this select 1;

_center = getPos _yellow;
_radious = 20; // Radious, distance between red and yellow
_angspd = 5;  // Angle ingrements in degrees per each loop
_ang = 0; // Initial angle

while {true} do
{
   _red setPos [(_center select 0)+sin(_ang)*_radious,(_center select 1)+cos(_ang)*_radious, 0];
   _ang = _ang + _angspd;
   if (_ang > 360) then
   {
      _ang = _ang - 360;
   };
   sleep 0.1;
};

Offline Deadfast

  • Members
  • *
Re: Rotate objects around another one
« Reply #2 on: 12 Feb 2009, 22:21:29 »
Thanks a lot, works just great ;)