Teleporter
by Donavan Jones · in Torque Game Engine · 05/28/2005 (6:11 pm) · 6 replies
Hey guys. I want to make a teleporter. How do I combine The teleporter trigger the particles and the shape in a .cs file.
This is what I got so far, not mush but it is a lot for a beginer
datablock StaticShapeData(teleportert)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
category = "teleporter";
shapeFile = "~/data/shapes/teleporterpad/teleporterpad.dts";
};
All this does is drop my dts shape in a file in the mission tree under shapes and when you select it it drops the dts shape in the world
As you can see I want to make it a drag and drog item. I want to have a teleport in and teleport out so I can teleport between the two. I have the teleporttrigger in a .cs file along with the particles in a .cs file. No one does not have to give me the code but I want to understand how to combine them I could figure out the rest
I know I could create a dts shape and drop it in my level and create a particle system and drop that in my level and align them and finaly create my trigger and drop that in my level and align it with the dts shape and particles I want a complete "product" and use that over and over in my game because its already done.
Thanks
This is what I got so far, not mush but it is a lot for a beginer
datablock StaticShapeData(teleportert)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
category = "teleporter";
shapeFile = "~/data/shapes/teleporterpad/teleporterpad.dts";
};
All this does is drop my dts shape in a file in the mission tree under shapes and when you select it it drops the dts shape in the world
As you can see I want to make it a drag and drog item. I want to have a teleport in and teleport out so I can teleport between the two. I have the teleporttrigger in a .cs file along with the particles in a .cs file. No one does not have to give me the code but I want to understand how to combine them I could figure out the rest
I know I could create a dts shape and drop it in my level and create a particle system and drop that in my level and align them and finaly create my trigger and drop that in my level and align it with the dts shape and particles I want a complete "product" and use that over and over in my game because its already done.
Thanks
About the author
#2
with just:
it's easier and more robust because it doesn't rely on the coordinates being the first dynamic field.
08/30/2007 (11:45 am)
You know, you could replace this:// here is where we do the real work %str = %trigger.getDynamicField(0); // it should remove the name of the dynamic field and leave the coordinates %coords = removeField(%str, 0);
with just:
%coords = %trigger.coords;
it's easier and more robust because it doesn't rely on the coordinates being the first dynamic field.
#3
08/30/2007 (1:46 pm)
Thx, I thought I did try that but didn't work, I was obviously doing something wrong because I just did it and works fine!!
#4
08/30/2007 (2:46 pm)
Another option is telling the teleport trigger the name of a Marker object (or any object for that matter) that is the target of the teleporter. Then just use the target's transform when someone enters the trigger. This allows you to move the target easily inside the editor.
#5
09/02/2007 (9:38 am)
I got the teleport to work, but what I wanted was to mount the emitter to the teleporter shape so when I move the shape the emitter will move too.
#6
Tony
09/10/2007 (11:13 am)
You can also use the RPGDialog resource to create NPC's that teleport the character to other locations. Just my 2 cents.Tony
Torque Owner JuanMa
First of all there is a resource that has been around for some time click here. I have never used it, so I do not know how it works.
Also I have been working on a generic trigger call teleporter, it should be a cheap way to achieve similar results. This will not show fancy particle emitter or lights.
This particular trigger assumes that you will have a single dynamic field that will contain the coordinates.
First of all go to your server directory server/scripts/triggers.cs and add this code at the end of the file:
datablock TriggerData(Teleporter) { tickPeriodMS = 100; }; //----------------------------------------------------------------------------- function Teleporter::onEnterTrigger(%this,%trigger,%obj) { echo("Teleporter::onEnterTrigger --IN"); Parent::onEnterTrigger(%this,%trigger,%obj); // Print out some debug info ;) // Get the number of dynamic field in the trigger echo("# Of Indx : " @ %trigger.getDynamicFieldCount()); // in my case I just have one so I use the first index echo("Index 0 : " @ %trigger.getDynamicField(0)); // here is where we do the real work //%str = %trigger.getDynamicField(0); // it should remove the name of the dynamic field and leave the coordinates //%coords = removeField(%str, 0); %coords = %trigger.coords; // Updated, thx Orion Elenzil // for educational purposes print out the string and the coordinates echo("The String : " @ %str); echo("Coordinates : " @ %coords); // this transform will take you to the place that you want!! %obj.setTransform(%coords); } //----------------------------------------------------------------------------- function Teleporter::onLeaveTrigger(%this,%trigger,%obj) { Parent::onLeaveTrigger(%this,%trigger,%obj); } function Teleporter::onTickTrigger(%this,%trigger) { Parent::onTickTrigger(%this,%trigger); }The trigger should look like this on your *.mis file where coord is the dynamic data field
new Trigger(TestTrigger) { canSaveDynamicFields = "1"; position = "647.288 -1344.81 112.729"; rotation = "1 0 0 0"; scale = "1 1 1"; dataBlock = "Teleporter"; polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000"; coords = "-9 -1414 50 0 0 1 0"; };Hope it helps
Juanma