Tele Chair
From GMod Wiki
Contents |
Tele Chair
Tele Chair: Tele Chair |
Description: | Allows the user to teleport anywhere in a chair using a Cam Controller. |
Original Author: | Entoros |
Created: | December 28, 2008 |
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.
- Spawn a leather Office Chair vehicle.
- On the back, spawn a Cam Controller ("Static" unchecked) and an Advanced Pod Controller. Link the Adv. Pod Controller to the Office Chair.
- Spawn a Hover Drive and weld it to the chair.
- Spawn two wire Numpads; one untoggled (Value On: 1, Value Off: 0) and one toggled (Value On: 50, Value Off: 1).
- 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() }
- Note: there's no more need for a target finder; just put your name where it says "YOUR NAME HERE".
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:
- Wire the "On" to the "On" of the Cam Controller.
- 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.
- Wire the "Activated" to the "Active" of the Adv. Pod Controller.
- Wire the "Zoom" to the "0" of the toggled Numpad (make sure to keep track).
- 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.
- Wire the "X_JumpTarget" to the "X" of the Cam Controller, "Y_JumpTarget" to the "Y", etc.
- Wire the "SetJumpTarget" to the "Mouse1" of the Adv. Pod Controller.
- 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.
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:
- Change the key inputs (i.e. use WASD instead of 2468 to maneuver the Cartesian plane).
- Set the JumpTargets to the CamX instead of the X of the CamController (makes you teleport to the position of the Camera, not where the Cam is looking at).
- Change the multipliers in the SumX/Y/Z section (makes pressing a button move the camera more or less).
- Change the toggled Numpad's On value (higher the value, the farther it zooms out).
- Add an option to change the "Roll" of the Camera with the / and * keys (although why you would want to do that, I have no clue).
- By changing some of the E2 chip you could probably make it always go in the direction you are facing, using Entity:angles():yaw() and sin/cos, or something like that. E.g:
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.