+12

Hyper's Tools

Hyper 3 years ago updated 3 years ago 1

Today I wanted to share some of the small helper tools I've made for myself. It's a set of 15 divided in three categories: Flow and logic, Math, and Vectors. Descriptions and zip file with the .assets below the pic.


FLOW AND LOGIC

  • Float to Bool: Converts a float to a boolean value. Values larger than 0 return true, while lower than 0 return false. Default for zero is false but can be toggled to true.
  • Bool to float: Converts a boolean to a float value. True returns 1, false returns 0, but can optionally be set to return -1. Very useful when taking boolean values from events or superunit inputs and converting them for direct math use and not need Select units
  • Counter: Counts from A number to B number. Doesn't matter if its ascending or descending. Can be set to wrap back to the start, and to also include the starting number. If the start and end numbers are set to the same it returns invalid.
  • Do Once Then: Does something only once and afterwards does something else. Has a reset port.
  • FlipFlop: Switches the flow output every time it is entered. It always starts on A and then flips to B, back to A, etc. Has a return boolean and reset port too.
  • Branch Toggle: Like the normal branch unit, but returns a boolean value that is the inverse of the incoming boolean. The flow is executed first so the incoming boolean is true, returns true flow and then returns a false bool.
  • Branch Switch: This one diverts the flow in a more advanced manner than the usual branch. Given a boolean input, the switch will flow continuously on true / false through the corresponding ports (like branch), but it will also output one time pulses when the boolean changes from false to true (switched on) or from true to false (switched off). It also returns the present state of the switch.

MATH

  • Decimals: Receives a float value and cuts off the decimals that exceed the specified precision value, rounding them either to ceiling (up) or floor (down).
  • Get Sign: receives a float and returns it as a normalized value with sign (1 or -1), with the choice of how to treat zero. Useful with the bool <> float tools to convert numbers into boolean logic.
  • Negate Float: Reverses the sign of a float (multiplies it by -1)

 VECTORS

  • Negate V3: Reverses the direction of a V3 (multiplies all its components by -1)
  • Get XYZ: Gets all 3 components without having to use the individual get X get Y, get Z. Also much more compact and specific than using expose.
  • Replace V3: Takes a V3 and replaces the value of its components with a specific number, with toggles for each component, as well as outputs. This can be used as a much more advanced Get XYZ to filter and replace values in a single unit, say get rid of a component by zeroing selectively.
  • Add to V3: Adds to the components of a V3 individually, so you can choose what value to add (or subtract) to each without having a ton of Get (), Add, units. If you don't attach a vector to the port you can also fill in the values to create a new one. There is a boolean to choose substraction instead (effectively reverses the sign of all inputs).
  • Multiply V3: Just like Add to V3, but with multiplication / division. 


Get them here, they're just macros so you can modify them to your needs:

Hyper's Tools V1.0

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+3

Ok after a little bit of extra testing I found some flaws and made some improvements, as well as two new flow/logic units so here's an update:

Hyper's Tools V1.1.zip

  • Flow Switch: Unlike the Boolean switch, this does not require an input boolean to switch its state; instead it switches based on incoming flows. You still get a boolean to define its initial state. Otherwise it provides the same outputs (in fact its mostly a Boolean switch inside; it can use some internal optimizing).
  • Flow to Bool: Not to be confused with Float to Bool, this one generates a desired boolean output only when entered... and the opposite boolean when its output port is being called but its not entered. So if it is set to Flow = true, then its output port will produce false, until the unit receives a control input which will make it emit true. This allows one to turn flows straight into boolean values to be further used for logical operations. (It still is somewhat of an experiment, will probably be tweaked further.)

Here's Flow Switch and several of the other units working together to create an On Hold behavior that listens to two keys being held down together, and after a given count, emits a single flow pulse that triggers the final toggle to switch gravity on or off, with the counter and once filter being reset after the input is released. (I know keyboard input has hold events, but this is just an example). Flow AND is still an experiment but hopefully it will be released soon with other Flow Logic Gates...

Here's Flow to Bool being used to execute boolean operations that are based on flows without having to use a bunch of variables.


CHANGELOG

V1.1

Counter: Removed start unit. Fixed end output not working, added Lap counter.
Do Once Then: Added fallback value. Also And option.
FlipFlop: Removed start unit by adding fallback value.
Branch Toggle: Added default value of false to Branch Toggle input boolean.
Branch Switch: Renamed to Boolean Switch (its more relevant to how its controlled). Removed start unit by adding fallback value. Added force on and off input ports.
Decimals: Changed default value to 2.
Added Flow Switch (needs internal redesign but it works)
Added Flow to Bool (needs more testing but I'm putting it out there anyway)