Rotating Platform Speed Changer


Posted by Maj.Bitch (24.95.222.*) at 1:54 PM, 5/20/2001:


Heheh.. You know that big rotating entity on Q2DM1 which slowly rotates around by the quad and railgun? Well, I was playing around to see what it would take to make that thing whip around so I put this together and it was pretty cool so I thought I'd post it.

What it does is when the game engine spawns the rotator entity into the map, a separate speed changer entity also gets spawned by the rotator's spawn function. The speed changer will think every 20 seconds and cause the rotator to spin around quite rapidly and on the nextthink in 20 secs it'll restore its speed back to normal. Also, if you want, you can make the rotator entity NON-SOLID (so it passes right thru players) and then return it back to SOLID_BSP like normal. Lot's of interesting things you can do to the entity once you've got the speed changer spawned! Be imaginative!

Find your SP_func_rotating() function (the one which uses the rotating_use() and rotating_blocked() functions.

At the bottom, add this:

  InitSpeedChanger(plat);

Now, right above your SP_func_rotating function, add these 2 routines:


//=====================================================
void eThink(edict_t *e) {
static int i=0;

  if (i==0) {
// e->owner->solid=SOLID_NOT; // uncomment to make pass thru players
// VectorNegate(plat->movedir,plat->movedir); // uncomment to make go in reverse
   VectorScale(e->owner->avelocity,10,e->owner->avelocity); // increase speed by 10x
    i=1; }
  else {
//  e->owner->solid=SOLID_BSP; // restore to normal
// VectorNegate(plat->movedir,plat->movedir); // restore to normal
    VectorScale(e->owner->movedir,e->owner->speed,e->owner->avelocity); // restore to normal
    i=0;
 }

  gi.linkentity(e->owner);

  e->think=eThink;
  e->nextthink=level.time+20.0;
}


//=====================================================
void InitSpeedChanger(edict_t *plat) {
edict_t *e;
  e=G_Spawn();
  e->owner=plat;
  e->svflags|=SVF_NOCLIENT;
  e->think=eThink;
  e->nextthink=level.time + 10;
  gi.linkentity(e);
}

That's it!

 

I'm gonna spend a bit of time playing around with my func entities to see what other interesting stuff I can make happen. Was thinking about trying to make an elevator platform go up so fast that the guy launches straight into the air!! heheh

Have fun!

Maj.Bitch




Replies:             (Local time is: 12:56:16 PM, 4/23/2004)

TUTORIAL: Rotating Platform Speed Changer - Maj.Bitch at 1:54 PM, 5/20/2001 (5 replies)