Tele Chair

From GMod Wiki

Jump to: navigation, search



Contents

Tele Chair

Tele Chair: Tele Chair
Page white text.png Description:Allows the user to teleport anywhere in a chair using a Cam Controller.
link=User:Entoros Original Author:Entoros
Calendar.png Created:December 28, 2008
Page white text.png Notes:This is a suckish version! I am suckish at Expression 2! Please help me make it better. Also, all credit goes to Gwahir for the entire idea + the look! (Sorry, too great of an idea to pass up! :D)


Getting the Parts

To start out, let's get everything together first. Just a note; because I really don't want to take the time to lay everything out in gates right now, it's all packed into Expression 2. Sorry; I'll get to it eventually, and it'll be explained at the end.

A basic view of the chair.
  1. Spawn a leather Office Chair vehicle.
  2. On the back, spawn a Cam Controller ("Static" unchecked) and an Advanced Pod Controller. Link the Adv. Pod Controller to the Office Chair.
  3. Spawn a Hover Drive and weld it to the chair.
  4. Spawn two wire Numpads; one untoggled (Value On: 1, Value Off: 0) and one toggled (Value On: 50, Value Off: 1).
  5. Spawn an Expression 2 with the following code:
@name TeleChair
@inputs On N1 N2 N3 N4 N6 N7 N8 N9 Enter Plus Period Active
@outputs CamX CamY CamZ CamPitch CamYaw 
@persist SumX SumY SumZ Player:entity
Player = findPlayerByName("YOUR NAME HERE")
SumX += (N8 + -N2)*100
SumY += (N4 + -N6)*100
SumZ += (Plus + -Enter)*100
if(Active){
    CamX = Player:pos():x() + SumX
    CamY = Player:pos():y() + SumY
    CamZ = Player:pos():z() + SumZ + 5
    CamYaw += (N7 + -N9)*15
    CamPitch += (-N3 + Period)*15
}
else{
    CamX = Player:pos():x()
    CamY = Player:pos():y()
    CamZ = Player:pos():z()
}

Wiring the Components

Most of the wiring is pretty self explanatory, but I'll walk you through just to make sure everything is wired up right. There's a lot of inputs/outputs, so there's a good chance of error.

First, the Expression 2 chip:

  1. Wire the "On" to the "On" of the Cam Controller.
  2. Wire the N1 to the "1" of the untoggled Numpad, N2 to the "2", and so on and so forth (including Enter, Plus, and Period).

Next, the Cam Controller.

  1. Wire the "Activated" to the "Active" of the Adv. Pod Controller.
  2. Wire the "Zoom" to the "0" of the toggled Numpad (make sure to keep track).
  3. Wire the "X" to the "CamX" of the Expression2, "Y" to the "CamY", "Z" to the "CamZ", "Pitch" to the "CamPitch", and "Yaw" to the "CamYaw".

Lastly, the Hover Drive.

  1. Wire the "X_JumpTarget" to the "X" of the Cam Controller, "Y_JumpTarget" to the "Y", etc.
  2. Wire the "SetJumpTarget" to the "Mouse1" of the Adv. Pod Controller.
  3. Wire the "Jump" to the "Mouse2" of the Adv. Pod Controller.

Also, make sure to link the Pod Controller to the chair.

The Finished Product

Whew! Now that everything's wired up and ready to go, let's take this baby out for a spin. Here are the controls:

8 = Forward the Y Axis; 2 = Back the Y Axis

4 = Left on the X Axis; 6 = Right on the X Axis

+ = Up on the Z Axis; Enter = Down on the Z Axis

7 = Pan left (Yaw left); 9 = Pan right (Yaw right)

3 = Look up (Pitch up); Period = Look down (Pitch down)

0 = Zoom in and out.

Me looking down at myself through the Camera (quite an out of body experience)

Now that you can move the Cam Controller, you can move wherever you want. The Chair will teleport to wherever the Cam Controller is looking at, not to the Cam Controller's position! So, make sure you're looking at the ground. To teleport, left click then right click with the mouse. Also, the 2468 keys control your movement in the XY plane; this means that as you change your yaw or pitch, the XY plane doesn't move, so if you turn around and find yourself going backwards by pressing the forwards button, that's just how it is. It can be easy to get disoriented while trying to cam your way around, so always try looking around with the pitch and yaw buttons.

Changing it Up

Here's a couple things you can change with the contraption:

  E=Entity:angles():yaw()
  Y=sin(E)
  X=cos(E)
  Entity:applyForce(vec(X,Y,0))(this can also be used in applyForce)

Explanation

It's pretty simple, actually. The Cam Controller is just a viewpoint that looks at moves to specific coordinates with certain pitch/yaw/roll. What we're doing is telling the Camera to first look at us, then to move around to different X/Y/Z coordinates using the Numpad as inputs. The Hover Drive teleports to X/Y/Z coordinates, so because the Camera outputs the X/Y/Z coordinates of where it's looking, we can teleport to wherever the Camera looks. Thus, we can teleport anywhere on the map by controlling the Camera.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox