Game Development Community

Jumps in the same zone..

by Jan Sorensen · in Torque Game Engine · 07/25/2010 (1:14 pm) · 5 replies

Hi here :-).

Maybe a simply question to the good old TGE..

Please can anybody here give me a hint to how (on the simply way) I make a trigger (placed in triggers.cs) there brings me/my player to 'a named spawnpoint' in the same zone as the trigger, without re-loading the zone, just jump to there.

Something like this in 'triggers.cs':

// Jump to Named Spawn-point Trigger.
if (%trigger.nameTag $= "JumpToSpawn") {

if (%obj.getClassName() $= "Player") {
'Jump to 'Spawn-point...'
}
}

Have a problem with the 'syntax' here.

Regards and hope for help Jan :-).

#1
07/25/2010 (4:22 pm)
Teleport Script (with Triggers) and Teleport via Script are two similar but differently implemented methods you could check out.

The actual jump to point syntax would be passing the object that is being teleported and a location to the setTransform function, something like this command.
%player.setTransform(%pos);
with appropriate parameter names of course
%player = the objectID of what is being teleported
%pos = X Y Z location in 3d space to move the object to
#2
07/25/2010 (7:33 pm)
Hi Michael and thanks for answers :-).

I have do this (where %obj is the player) and insert it as a part in a trigger function in 'triggers.cs' and its work very fine :-).

// Teleport trigger
if( %trigger.nameTag $= "TeleportTrigger" && %obj.getClassName() $= "Player" )
{
%targetObj = %trigger.SpawnName;
%player = %obj;
%currPlayerPos = %player.getPosition();
%targetPos = %targetObj.getPosition();
%x = getWord(%targetPos, 0);
%y = getWord(%targetPos, 1);
%z = getWord(%targetPos, 2);
%finalPos = %x SPC %y SPC %z;
%player.setTransform(%finalPos);
}

But I have two question more..

1: How can I be sure the player 'spawn' with the 'nose' in the 'Y-direction' in my 'Spawn-WayPoint marker'.

From the .mis file:

new WayPoint(OutOfGalleri) {
position = "-299.618 453.124 2.8";
rotation = "0 0 -1 89.9544";
scale = "1 1 1";
nameTag = "1";
dataBlock = "WayPointMarker";
team = "0";
};

2: To be sure my new trigger works, also via 'server' (can't test this in this moment).. Shall I use something with a 'CMD call someplace, or?

Regards Jan :-).
#3
07/26/2010 (12:38 am)
Answers
1. To factor in rotation use GetTransform and SetTransform

// Teleport trigger
if( %trigger.nameTag $= "TeleportTrigger" && %obj.getClassName() $= "Player" )
{
   %targetObj = %trigger.SpawnName;
   %player = %obj;
   %currPlayerPos = %player.getTransform();
   %targetPos = %targetObj.getTransform();
   %player.setTransform(%targetPos);
}

For question number 2 im not sure what is being asked
#4
07/26/2010 (11:04 am)
Hi Scooby and thanks for answers :-).

Your example works also fine, but there was something I have misunderstand. A test show me the player come out of the marker exactly in the same direction he go into the trigger and that is a much better solution for me, so question number '1', it's not necessary for me more :-).

With question number two I mean, a 'Dedicated server'.. Sorry. It is my experience that the 'client / server' on the same computer, just do not behave the same way as 'client/Dedicated-server' (separate server computer), but I have found a way to test this to.

Thanks for help, Jan :-).
#5
07/26/2010 (10:30 pm)
Just a short comment..

It's also work fine with a Dedicated server, tested today, no prob.

Jan :-).