Game Development Community

True" teleporting

by Alberto Ganesh Barbati · in Torque Game Engine · 05/29/2006 (4:31 am) · 8 replies

Hi,

I would like to teleport an object. I thought this would be as simple as issuing a setTransform() in server-side scripts and in fact the teleport script resource agrees with my understanding. The problem is that on the client the object (which is an instance of RigidShape) does not "warp" direcly to its new position, but it's rather moved very quickly there because of the network interpolation code. One solution could be to make the object disappear/reappear with setHidden and/or startFade, but you have to guess the time needed by the client to resync to the new position. Unfortunately, such approach does not help me, because my camera is third-person and orbits the teleported object, so it will track the movement of the object even if it's hidden, with a very unpleasant effect.

Any idea?

Thanks in advance,
a.b.

#1
05/29/2006 (4:35 am)
Can't you delete the object, then create a new one in new position?
#2
05/29/2006 (4:40 am)
Have you tried setting the noWarpMask?

Anyway. In unpackUpdate there's an if statement which controls warping and interpolation. If you set this if statement to also check if you're teleporting, you'll get the effect you're looking for.

Ie. When we reach the original if statement, check if teleporting is true, if it is, skip the parts where interpolation occur, and set teleporting to false.

The vehicle should now "warp" to it's position rather than interpolate.

Edit: Tried to make myself more clear.
#3
05/29/2006 (8:12 am)
@Paul: in theory I could do it, but the object is the player itself so it is a bit impractical as there may be other objects depending on it always be present

@Stefan: the NoWarpMask looks interesting. It's done in the Item class, but I see no apparent technical problem to reproduce the same behaviour also into my RigidShape class. I'll try it at once. Thanks for the info.
#4
05/29/2006 (8:30 am)
I'm planning on making an effect where you go from visible to invisible to visible then teleport and become visible with some particle effects like Star Trek
#5
05/29/2006 (8:40 am)
It works! In fact, the main point I was missing was precisely the idea that I could use setMaskBits() to specify that the warp has to occur *only* in the next packet update. Brilliant! Thanks again, Stefan.
PS: I find amusing that setting the flag NoWarpMask in fact makes "warping" happen. It seems that the people at GG used the term "warp" with exactly the opposite meaning as myself ;-) Better avoid this term next time to avoid confusion.
#6
05/29/2006 (9:06 am)
@Brian: sounds a nice effect. However, once you have tweaked setTransform() to do a real teleport, then you can easily achieve that effect through script only. For example:
function teleport(%object, %transform)
{
  %object.startFade(1000, 0, true);
  schedule(1000, %object, "teleportIn", %object, %transform);
}

function teleportIn(%object, %transform)
{
  %object.setTransform(%transform);
  startFade(1000, 0, false);
  // start you particle effect here
}
Without the tweaking, it might have happened that the object could have started to fade-in before reaching the final position.
#7
05/29/2006 (9:53 am)
I was thinking of using schedule and a counter that would go up everythime the function is called then when the counter is a certain # it resets, starts the particles, then teleports and when it is done teleporting it just reverses
#8
05/29/2006 (10:30 am)
Quote:
PS: I find amusing that setting the flag NoWarpMask in fact makes "warping" happen. It seems that the people at GG used the term "warp" with exactly the opposite meaning as myself ;-) Better avoid this term next time to avoid confusion.

lol. I was confused by that one too.
Glad you got it working! :D