Rotating Doors - Where am I wrong?

Posted By: Loremaster

Rotating Doors - Where am I wrong? - 03/17/13 23:35

Where am I wrong: In the Shooter-Template there is a relatively large function to revolve doors using pan-values and angle-calcualtions. I thing this is very complicated. To use a swinging door, I create a model that swings open and use the following limerick to open it.

Code:
action ThingAnimates () {
while(1) 
   {
      my.skill1 += 3*time_step;
      if (my.skill1 > 100) my.skill1 -= 100; 
      ent_animate(me,"Open",my.skill1,ANM_CYCLE);
      c_updatehull(my,1);
      wait(1);
   }
}



c_updatehullk makes sure the ColDet stays precise. The BB works, I've checked using the f11-key. It's a breeze and I have made it, therefore I am VERY suspicious. Is there anything wrong with that approach?
Posted By: 3run

Re: Rotating Doors - Where am I wrong? - 03/17/13 23:52

Why do you need:
Code:
if (my.skill1 > 100) my.skill1 -= 100;

Using "ANM_CYCLE" will already make it cycle from 0 to 100 and then from 0 again.

I would do it this way:
Code:
action actDoor(){
	// reset skill for animation:
	my.skill1 = 0;
	// animation loop:
	while(my.skill1 < 100){
		// animations speed:
		my.skill1 += 3 * time_step;
		// animate the door:
		ent_animate(my, "frame", my.skill1, ANM_CYCLE);
		// wait one frame:
		wait(1);
	}
	// as we've played the animation, fix the bounding box:
	c_updatehull(my, 10); // insert the last animation frame, instead of 10
}

BTW, I don't really think, that rotation the PAN angle of door, without any collusions is really slow or so laugh
© 2024 lite-C Forums