Game Development Community

Visual Jitter/Lag with changing size and mounts

by Johannes Pauw · in Torque Game Builder · 02/16/2012 (10:02 am) · 4 replies

I have a game where two objects are mounted together with an offset. I use a simple schedule to change the size of both objects simultaneously. When I do so, the object that is mounted seems to have a fraction of a second of lag as it changes its position.

My code looks something like this:


...
%cardImage.mount(%card, 0, -0.25);
%card.graphic = %cardImage;
...

function Card::sizeCard(%this, %size)
{
   %this.setSize(%size * 2/3, %size);
   %this.graphic.setSize(%size * 1/3, %size * 1/3);
}

function Card::expandCard(%this)
{
   if (%this.getSize().y >= 40)
   {
      %this.sizeCard(40);
   }
   else
   {
      %this.sizeCard(%this.getSize().y + 5);
      %this.sizingCallback = %this.schedule(32, expandCard);
   }
}

I'd really really prefer to put these cards together from smaller pieces, but the visual lag is extremely distracting and quite frankly unacceptable for a commercial product. Does anyone have any idea what's going on here?

#1
02/16/2012 (1:45 pm)
Try dismounting, change sizes/positions, then mounting?
#2
02/16/2012 (1:59 pm)
Dismounting/remounting is a good workaround :). Thanks for the tip Ronny.
#3
02/16/2012 (2:01 pm)
I've had a similar problem. Ultimately, I will probably stop "mounting" but my current hack is at least better than the regular mount, and it is a lot like @Ronny's suggestion:

For each mount, I mount, then I unmount, then I mount again. :)

Or in your case, probably, unmount, change, mount back.

My guess is that the problem has to do with the physics engine. Ultimately I feel all "mounting" is probably too closely tied to some idea from the physics simulator realm.

I may start doing my own "keep things linked together" for my simple needs.
#4
02/18/2012 (11:52 pm)
Note that mounting adds a linkpoint at runtime, so don't do it too often (like every frame, or in an onUpdate), as you'll soon run up to thousands of linkpoints which will drastically slow your game down. If this operation is only happening every few seconds it won't be a problem.