Game Development Community

Teleporting

by Mike G · in General Discussion · 01/27/2012 (11:01 am) · 6 replies

I am trying to make a code where i can teleport to other players or teleport them to me. I am trying to figure out how to change my position by typing in 12 15 14 basicly.
function TPCODE::setPOS()
{

    %tempHolder = LocalClientConnection.getControlObject();

    %tempHolder = %tempHolder.getposition();

    TP_PositionSelector.text = %tempHolder;
}
This is the script that lets me find my position. How would i set my current position without going into editor?

THANKS!

#1
01/27/2012 (12:15 pm)
There's also a setPosition to go along with getPosition.

So for instance:

%myObject.setPosition(%positionToMoveTo);
#2
01/27/2012 (12:19 pm)
@Mike G - Something like this:

// Center of the world. Replace with your actual TP position
%teleportPosition = "0 0 0";
%rot = getWords(%player.getTransform(), 3, 6);
%targetPosition = %pos SPC %rot;
%player.setTransform(%targetPosition);

We cover this in the T3D 1.2 demo/tutorial.
#3
01/27/2012 (1:10 pm)
@Michael Perry

How would i use that code to select my position from a UI?
I want to be able to type the code in and go to that position.
Thanks!
#4
01/27/2012 (1:35 pm)
@Mike G - I'm not quite following. So you want to type the position in a GUI and then use that to teleport?
#5
01/27/2012 (5:52 pm)
Yes. My goal was to be able to teleport to players. All i want to do is type their coordinates and teleport their.
#6
01/27/2012 (6:30 pm)
Once you get the text coordinate, you need to send it across the network.

function WarpPlayer(%position)
{
   commandToServer('TeleportPlayer', %position); 
}

serverCmdTeleportPlayer(%client, %position)
{
   %rot = getWords(%player.getTransform(), 3, 6);  
   %targetPosition = %position SPC %rot;  
   %client.player.setTransform(%targetPosition); 
}

You should check out the section of the FPS Tutorial that covers networking: Networking in T3D