Make an actor orbit around a mapspot in a certain time (ACS)

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Tormentor667
Posts: 13527
Joined: Wed Jul 16, 2003 3:52 am

Make an actor orbit around a mapspot in a certain time (ACS)

Post by Tormentor667 »

I need to make an actor orbit around a specific map spot with a specific distance in a specific amount of time. How can I do that ACS-wise?

**EDIT**
Managed to solve what I wanted with a spherical model, was the easier way to go.
Last edited by Tormentor667 on Sat Dec 02, 2017 6:20 am, edited 1 time in total.
User avatar
KeksDose
 
 
Posts: 595
Joined: Thu Jul 05, 2007 6:13 pm

Re: Make an actor orbit around a mapspot in a certain time (

Post by KeksDose »

Your easiest bet is to use Warp, that is, if you want to have a completely horizontal orbit (having a tilted orbit is possible, but slightly trickier on the maths, and I don't want to distract from the general idea). In any case, you'd imagine the motion like a spinning centrifuge, so we'll work with an angular velocity, I guess.

To complete one orbit in a specific time, you'd divide a full angle, 1.0 in acs, by the time in tics. You add the resulting value to the current angle, each tic. The rest is using flags with Warp and setting the script activator correctly (Warp is kinda annoying to use).

Code: Select all

int orbit_tics = 35 * 60;
int orbit_lenf = 600.0;

int ang = 0;
int ang_vel = 1.0 / orbit_tics;

int middle_tid = 420;
int orbiter_tid = 1337;

bool orbiting = false;

// This skips orbiting if no actor with the specified orbiter_tid exists:
if(SetActivator(orbiter_tid)) {
   orbiting = true;
}

else {
   Log(s:"Orbit script: Couldn't set activator to tid: ", i:orbiter_tid);
}

while(orbiting) {
   // Move the orbiter and keep angle in normal range:
   ang += ang_vel;
   if(1.0 <= ang) {
      ang -= 1.0;
   }

   // This warps the activator (guaranteed to be orbiter_tid at this point)
   // to middle_tid at orbit_lenf distance at the specified angle:
   Warp(middle_tid, orbit_lenf, 0, 0, ang, WARPF_INTERPOLATE);
   Delay(const:1);
}
User avatar
Tormentor667
Posts: 13527
Joined: Wed Jul 16, 2003 3:52 am

Re: Make an actor orbit around a mapspot in a certain time (

Post by Tormentor667 »

Thanks kindly for that detailed explanation, but I think I've made a mistake... actually the orbiting needs to be pitchable and rotatable freely. Maybe I think the better solution in this case is to use a model instead of a rotation object that simply looks like something is orbiting around. In this unique case, I simply need to make a sun and a moon orbit in a skybox.

Return to “Scripting”