Holo Circle
From GMod Wiki
This page has been nominated for deletion. Deletion is due within approximately 30 days from nomination, unless the deletion has been disputed on the talk page. See more pages nominated for deletion here. Reason for deletion: Not what Garry wants the wiki to be used for Last Edit was made on 11/16/2011 |
Contents |
Holo Circle
Holo Circle: Holo Circle |
Description: | Creates a continuous circle with a HoloEmitter. |
Original Author: | Entoros |
Created: | December 22, 2008 |
Notes: | Refer to my Double Holo Helix tutorial for a more advanced Holo technique. |
Getting the Parts
To start out, we need to spawn all of the components necessary to make the holo circle happen. Bear in mind there may be quite a few gates; if you're experienced in expression, I'll copy the code if you'd like. If you're not sure where to place things, look at the image. So, to start out, follow these steps:
- Spawn something to put it all on. A PHX 1x1 or 2x2 plate is a good prop.
- Go to your Wire tab, scroll down until you find the HoloEmitter tool. The CLIENT: Max fade time slider defines the maximum time (in seconds) it can take for a holo to fade for your client (not the spawned emitter). Set it to something like 5 or something. Spawn the HoloEmitter at the top of your plate.
- Next, spawn a "timer" gate (under the "Gate - Time" menu) at the bottom of the plate.
- Above the timer gate, spawn two "multiply" gates ("Gate - Arithmetic").
- Then, under the "Gate - Trig" menu, spawn one of the "sin(rad)" and "cos(rad)" gates above the multipliers.
- Above those trig gates, spawn two more multiply gates.
- In the middle of all of these gates, spawn a "Constant Value" ("Wire - I/O") with number values of 1, 2, 3.14 (pi) and 50.
- In the middle of the plate, spawn a wire Button, "Toggle" checked, with a Value On of 1 and a Value Off of 0.
Wiring the Components
Now that everything's spawned and ready, let's start wiring things up. If you get confused, refer back to the image of the finished product.
- Wire the "Run" of the timer to the constant value of 1.
- Wire the "A" of the first and the second multiplier to the timer and the "B" to the value of 2.
- Wire the "A" of the sin(rad) to the first multiplier and the "A" of the cos(rad) to the second multiplier.
- Wire the "A" of the third multiplier to the sin(rad) and the "B" to the value of 50.
- Wire the "A" of the fourth multiplier to the cos(rad) and the "B" to the value of 50.
- Wire the "X" of the HoloEmitter to the third multiplier.
- Wire the "Y" of the HoloEmitter to the fourth multiplier.
- This wont currently work, as the holoemitter only has a vector input (will be changed soon). For now, go to Gate - Vector and create a compose gate, then wire the emitters vector input to the gates vector output and treat the gate as the emitters x,y,z inputs.
- Wire the "Local" of the HoloEmitter to the value of 1.
- Wire the "FadeTime" of the HoloEmitter to the value of 3.14 (pi).
- Wire the "LineBeam" of the HoloEmitter to the value of 1 if you want a line between each holo
- Wire the "Active" of the HoloEmitter to the button.
It is done, now press the button and the HoloEmitter should start to make a circle. The only thing left to do is the most important thing, have fun and play around with what you wire and where you wire it!
The Finished Product
Now there's a couple different ways you can edit the circle. Here is a few of them, and some information about how stuff work, to help you understand everything.
- The second constant value (in this case, 2) controls how fast the circle spins; i.e. the higher the number, the faster the circle will be drawn by the holoemitter. A full circle in radians is 2*pi, and as the multiply in this case double the speed of the circle (half the time it takes to paint it), it will take pi seconds (2*pi/2 = pi) for it to paint the circle (which is why you set the faderate to pi)
- The third constant value (in this case, 50) controls the radius of the circle, which is how wide the circle is; the higher the number, the larger the circle.
- The fade time on the HoloEmitter controls how long time (in seconds) it takes for a holo to fade (0 is forever).
- The "Z" of the HoloEmitter, which we didn't wire, controls how high (up or down) the circle will be. The higher the "Z" value, the higher the circle will be.
- The "Local" of the HoloEmitter makes the position of the holo local to the emitter. Remember that the coordinate system will rotate with the emitter, so if you make a holo above it while the emitter is upside down, the holo will end up below the emitter.
Expression Codes
Expression 1:
[label] Holo Circle [inputs] [outputs] X Y X = (sinr(Timer*2)*50 Y = (cosr(Timer*2)*50 interval(20) Timer += 0.02
Expression 2:
@name Holo Circle @inputs @outputs X Y @persist Timer
X = (sinr(Timer*2)*50 Y = (cosr(Timer*2)*50 interval(20) Timer += 0.02
This is just the basic expression for the holocircle. You can add stuff for FadeRate or Z or whatever. Also, I'm pretty sucky in both Expression 1 and 2. If you see any errors in this, please tell.
Explanation
I'm not the greatest at trig or anything, but the math involved is actually pretty simple. When you take the sine or cosine of a constantly changing number, the sine/cosine goes steadily from -1 to 1. So when you set your X as the sine and your Y as the cosine, for whatever reason it goes around in a circle (hey, I'm still in geometry, OK?).