Teleporting to a moving object

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Teleporting to a moving object // Archive: Tech Forum

1  |  

Post by W!ZARD // Sep 4, 2007, 1:20am

W!ZARD
Total Posts: 2603
pic
It's pouring with freezing rain here so my partner and I have taken a day off from packing up our house for our impending move - after all, it all works out OK in the end and if it's not OK then it's not yet ended.;)


This has given me a chance to do some more work on my space scene. Here's the technical question for all you script magicians; is it possible to teleport to a moving object?


Here's the scenario; I have a big spaceship, complete with working elevators and sliding doors. I also have a smaller spaceship. I'd like to have the small ship circling around the big one with the option of teleporting back and forth between the two whilst remaining in FP mode. The idea is that by TPing to the smaller ship a viewer can get to see the outside of the bigger ship.


Any input on this probably needs to be aimed at the beginner level - I've figured how to get doors and elevators working but mostly by trial and error and religiously following Dele's videos!


Thanx in advance


WZRD:D

Post by frootee // Sep 4, 2007, 3:42am

frootee
Total Posts: 2667
pic
Hi Wizard.

I think what you need to do is this:


The simplest thing to do I believe is to connect the Output Matrix parameters (tx,ty, tz, rx, ry, rz) from your little ship as input values to the Teleporter script that Dele created.


This will require some relatively minor changes to Dele's script. Specifically, you will have to add input attributes to the teleporter script node for tx, ty, tz, and probably rx, ry, and rz (more on this in a moment).


In addition, in the transporter script itself, you will have to add code to copy those input parameters into local script variables. Dele's script already does this. Basically you just follow the same form.


Then, in the script, where we set the script variables for the Camera tx, ty, and tz (this is the part of the script where we access the Node.SubObject(D3DView,0) or something like that (off the top of my head; I don't have ts in front of me...), we want to set those values to our matrix input values:


The Node.SubObject(D3DView,0) line of code accesses the first object in the D3DView node. This is our First Person Navigation Camera View. So this is what we want to change. I believe we're doing something like this:


Cam= Node.SubObject(D3DView, 0)


and then doing this:


Cam.tx= some_value;

Cam.ty = some_value;

etc....


So in those lines of code, we want to set the Cam.tx, Cam.ty, etc. to our input matrix values; i.e., the little ship's coordinates, or some desirable location which is offset from the center of the little ship. Note here: Perhaps you would want to set the axes of your ships close to the edge so you can easily view the other ship immediately.


Then the last line that sets our view to the Cam parameters is left alone.


You could use the same teleporter script for both the little and big ship, if you pass a flag parameter in addition to the matrix parameters. The flag would be 0, for big ship, or 1, for little ship. Then, you would set your internal script matrix variables (tx, ty, tz, rx, ry, rz) depending on this flag state. You will have to check the state of the flag, then use the desired variables accordingly:


if (flag == 0)

{

use big ship coordinates

}

else

{

use little ship coordinates

}


Now, regarding the rx, ry, and rz values: You will probably want to be looking at the other ship instantly. So, you could orient the ships so they are 'facing' opposite each other on one axis. Take the x-axis, for example:


BigShip_x_axis = -LittleShip_x_axis


So when you are teleported, your avatar essentially makes a 180 degree turn, to face the opposite direction.


HTH!


Froo

Post by W!ZARD // Sep 4, 2007, 3:50am

W!ZARD
Total Posts: 2603
pic
HTH? Well sort of Froo - thanks. I don't really speak scriptese but your explanation actually makes sort of sense to me!


Like I said I'm a real novice with scripting but I'll have a dabble and see what I can come up with. Thanks again for your explaination.


Right now I can't even get Dele's TP trigger to work between two static sites but I'm sure to be holding my tongue wrong or praying in the wrong direction or something!


Time for bed now though - another busy day in the real world tomorrow.

Post by 3dvisuals dude // Sep 4, 2007, 3:58am

3dvisuals dude
Total Posts: 1703
pic
I'll be taking a look into ways to do this too over the coming week and will let you know what I discover which works along the way.

- Mark / 3dvisuals dude

Post by frootee // Sep 4, 2007, 4:01am

frootee
Total Posts: 2667
pic
No prob Wiz. I'm new to scripting too! Tell you the truth, I was typing this so I can remember it later! But it seems to make sense. I will take a crack at this this week also.

So maybe 3dv and I both will come up with more than one solution! The cool thing is, if we work on the problem from different points of view, we come up with solutions for other things too!


Froo


HTH? Well sort of Froo - thanks. I don't really speak scriptese but your explanation actually makes sort of sense to me!


Like I said I'm a real novice with scripting but I'll have a dabble and see what I can come up with. Thanks again for your explaination.


Right now I can't even get Dele's TP trigger to work between two static sites but I'm sure to be holding my tongue wrong or praying in the wrong direction or something!


Time for bed now though - another busy day in the real world tomorrow.

Post by trueBlue // Sep 4, 2007, 10:26am

trueBlue
Total Posts: 1761
pic
Hmmmm... me thinks Dele's Avatar Lock would work for this.
What do you think? :rolleyes:

Post by frootee // Sep 4, 2007, 10:42am

frootee
Total Posts: 2667
pic
well yeah that does sound like an easy alternative. :)


In fact that would be the easiest approach... what was I thinking earlier? Probably a foggy solution... not enough coffee..


Froo
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn