Spaceship Hoverball System

From GMod Wiki

Jump to: navigation, search

This is a tutorial that will teach you how to build a simple spaceship hoverball system. This is very useful for spaceships, mingebots, Giant robots and the like.

These Numpad inputs are just as an example, I prefer to use pod controllers.

When you press 8 on the number pad our platform should move up, 2 should move it down, and holding 5 will shut off all the hoverballs and send it into freefall (good for landings).


Up/Down

Ok, first, we'll build the up/down system.

Finished spaceship platform.
  1. Get yourself something to be your spaceship, for this I've just used a phx 4x4 metal plate.
  2. Obviously, spawn 4 hoverballs on the corners.
  3. Spawn a numpad input of 8.
  4. Spawn a numpad input of 2.
  5. Spawn two multiplication gates beside the outputs.
  6. Near the 8 input, spawn a constant value of 1.
  7. Near the 2 input, spawn a constant value of -1.
  8. Wire the "8 input" side multiplication gate. A the 8 input. B the constant value of 1.
  9. Wire the "2 input" side multiplication gate. A the 2 input. B the constant value of -1.
  10. Spawn an "add" gate, preferably somewhere towards the middle of the plate, for neatness.
  11. Wire it A the 8 input, B the 2 input.
  12. Wire the hoverball's A: Zvelocity. to the add gate.

You're done!

Press 8, and the platform rises. Press 2, and the platform lowers.

On/Off

Now, a simple modification to make it better.

  1. Spawn a numpad input (5).

Now, when you hold 5 down, The platform's hoverballs get turned off, and the platform goes into a freefall.

Expression

Now, because the "thinking" part of this system requires quite a few gates, It's very convienient to put this all into an expression gate. If you don't know how to use the expression gate, just copy this coding into the required boxes in-game.

The expression for up/down is as follows:

Inputs: Up Down
Outputs: H

H = Up + -Down


Obviously;

  1. Wire 'Up" to the output of whatever you want to trigger up movement.
  2. Wire "Down" to the output of whatever you want to trigger downwards movement.
  3. Wire the Zvelocity (on the hoverball) to the expression gate.


The expression for on/off is a little more complicated, but still manageable.

Inputs: Off
Outputs: H
A = Off > 1
B = Off < 1
H = B + -A
  1. Now, Wire "Off" to whatever you want to be able to trigger it with.
  1. Wire the B: Hovermode to the expression gate.


Nb.

-I wrote this tutorial for my good friend Dogmatix, who "could learn wire if he could be bothered."

-Wiremod.com Thread

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox