Create
Abort Abort If Abort If Condition Is False Abort If Condition Is True Add Health Pool To Player Allow Button Apply Impulse Attach Players Big Message Break Call Subroutine Cancel Primary Action Chase Global Variable At Rate Chase Global Variable Over Time Chase Player Variable At Rate Chase Player Variable Over Time Clear Status Communicate Continue Create Beam Effect Create Dummy Bot Create Effect Create HUD Text Create Homing Projectile Create Icon Create In-World Text Create Progress Bar HUD Text Create Progress Bar In-World Text Create Projectile Create Projectile Effect Damage Declare Match Draw Declare Player Victory Declare Round Draw Declare Round Victory Declare Team Victory Destroy All Dummy Bots Destroy All Effects Destroy All HUD Text Destroy All Icons Destroy All In-World Text Destroy All Progress Bar HUD Text Destroy All Progress Bar In-World Text Destroy Dummy Bot Destroy Effect Destroy HUD Text Destroy Icon Destroy In-World Text Destroy Progress Bar HUD Text Destroy Progress Bar In-World Text Detach Players Disable Built-In Game Mode Announcer Disable Built-In Game Mode Completion Disable Built-In Game Mode Music Disable Built-In Game Mode Respawning Disable Built-In Game Mode Scoring Disable Death Spectate All Players Disable Death Spectate Target HUD Disable Game Mode HUD Disable Game Mode In-World UI Disable Hero HUD Disable Inspector Recording Disable Kill Feed Disable Messages Disable Movement Collision With Environment Disable Movement Collision With Players Disable Nameplates Disable Scoreboard Disable Text Chat Disable Voice Chat Disallow Button Else Else If Enable Built-In Game Mode Announcer Enable Built-In Game Mode Completion Enable Built-In Game Mode Music Enable Built-In Game Mode Respawning Enable Built-In Game Mode Scoring Enable Death Spectate All Players Enable Death Spectate Target HUD Enable Game Mode HUD Enable Game Mode In-World UI Enable Hero HUD Enable Inspector Recording Enable Kill Feed Enable Messages Enable Movement Collision With Environment Enable Movement Collision With Players Enable Nameplates Enable Scoreboard Enable Text Chat Enable Voice Chat End For Global Variable For Player Variable Go To Assemble Heroes Heal If Kill Log To Inspector Loop Loop If Loop If Condition Is False Loop If Condition Is True Modify Global Variable Modify Global Variable At Index Modify Player Score Modify Player Variable Modify Player Variable At Index Modify Team Score Move Player To Team Pause Match Time Play Effect Preload Hero Press Button Remove All Health Pools From Player Remove Health Pool From Player Remove Player Reset Player Hero Availability Respawn Restart Match Resurrect Return To Lobby Set Ability 1 Enabled Set Ability 2 Enabled Set Ability Charge Set Ability Cooldown Set Ability Resource Set Aim Speed Set Ammo Set Crouch Enabled Set Damage Dealt Set Damage Received Set Environment Credit Player Set Facing Set Global Variable Set Global Variable At Index Set Gravity Set Healing Dealt Set Healing Received Set Invisible Set Jump Enabled Set Jump Vertical Speed Set Knockback Dealt Set Knockback Received Set Match Time Set Max Ammo Set Max Health Set Melee Enabled Set Move Speed Set Objective Description Set Player Allowed Heroes Set Player Health Set Player Score Set Player Variable Set Player Variable At Index Set Primary Fire Enabled Set Projectile Gravity Set Projectile Speed Set Reload Enabled Set Respawn Max Time Set Secondary Fire Enabled Set Slow Motion Set Status Set Team Score Set Ultimate Ability Enabled Set Ultimate Charge Set Weapon Skip Skip If Small Message Start Accelerating Start Assist Start Camera Start Damage Modification Start Damage Over Time Start Facing Start Forcing Dummy Bot Name Start Forcing Player Outlines Start Forcing Player Position Start Forcing Player To Be Hero Start Forcing Spawn Room Start Forcing Throttle Start Game Mode Start Heal Over Time Start Healing Modification Start Holding Button Start Modifying Hero Voice Lines Start Rule Start Scaling Barriers Start Scaling Player Start Throttle In Direction Start Transforming Throttle Stop Accelerating Stop All Assists Stop All Damage Modifications Stop All Damage Over Time Stop All Heal Over Time Stop All Healing Modifications Stop Assist Stop Camera Stop Chasing Global Variable Stop Chasing Player Variable Stop Damage Modification Stop Damage Over Time Stop Facing Stop Forcing Dummy Bot Name Stop Forcing Player Outlines Stop Forcing Player Position Stop Forcing Player To Be Hero Stop Forcing Spawn Room Stop Forcing Throttle Stop Heal Over Time Stop Healing Modification Stop Holding Button Stop Modifying Hero Voice Lines Stop Scaling Barriers Stop Scaling Player Stop Throttle In Direction Stop Transforming Throttle Teleport Unpause Match Time Wait Wait Until While
Ability Charge Ability Cooldown Ability Icon String Ability Resource Absolute Value Add All Damage Heroes All Dead Players All Heroes All Living Players All Players All Players Not On Objective All Players On Objective All Support Heroes All Tank Heroes Allowed Heroes Altitude Of Ammo And Angle Between Vectors Angle Difference Append To Array Arccosine In Degrees Arccosine In Radians Arcsine In Degrees Arcsine In Radians Arctangent In Degrees Arctangent In Radians Array Array Contains Array Slice Assist Count Attacker Backward Button Char In String Closest Player To Color Compare Control Mode Scoring Percentage Control Mode Scoring Team Cosine From Degrees Cosine From Radians Count Of Cross Product Current Array Element Current Array Index Current Game Mode Current Map Custom Color Custom String Damage Modification Count Damage Over Time Count Direction From Angles Direction Towards Distance Between Divide Dot Product Down Empty Array Entity Count Entity Exists Evaluate Once Event Ability Event Damage Event Direction Event Healing Event Player Event Was Critical Hit Event Was Environment Event Was Health Pack Eye Position Facing Direction Of False Farthest Player From Filtered Array First Of Flag Position Forward Game Mode Global Global Variable Has Spawned Has Status Heal Over Time Count Healee Healer Healing Modification Count Health Health of Type Hero Hero Being Duplicated Hero Icon String Hero Of Horizontal Angle From Direction Horizontal Angle Towards Horizontal Facing Angle Of Horizontal Speed Of Host Player Icon String If-Then-Else Index Of Array Value Index Of String Char Input Binding String Is Alive Is Assembling Heroes Is Between Rounds Is Button Held Is CTF Mode In Sudden Death Is Communicating Is Communicating Any Is Communicating Any Emote Is Communicating Any Spray Is Communicating Any Voice line Is Control Mode Point Locked Is Crouching Is Dead Is Dummy Bot Is Duplicating Is Firing Primary Is Firing Secondary Is Flag At Base Is Flag Being Carried Is Game In Progress Is Hero Being Played Is In Air Is In Alternate Form Is In Line of Sight Is In Setup Is In Spawn Room Is In View Angle Is Jumping Is Match Complete Is Meleeing Is Moving Is Objective Complete Is On Ground Is On Objective Is On Wall Is Portrait On Fire Is Reloading Is Standing Is Team On Defense Is Team On Offense Is True For All Is True For Any Is Using Ability 1 Is Using Ability 2 Is Using Ultimate Is Waiting For Players Last Assist ID Last Created Entity Last Created Health Pool Last Damage Modification ID Last Damage Over Time ID Last Heal Over Time ID Last Healing Modification ID Last Of Last Text ID Left Local Player Local Vector Of Magnitude Of Map Mapped Array Match Round Match Time Max Max Ammo Max Health Max Health of Type Min Modulo Multiply Nearest Walkable Position Normalize Normalized Health Not Null Number of Dead Players Number of Deaths Number of Eliminations Number of Final Blows Number of Heroes Number of Living Players Number of Players Number of Players On Objective Number of Slots Objective Index Objective Position Opposite Team Of Or Payload Position Payload Progress Percentage Player Carrying Flag Player Closest To Reticle Player Hero Stat Player Stat Player Variable Players In Slot Players On Hero Players Within Radius Players in View Angle Point Capture Percentage Position Of Raise To Power Random Integer Random Real Random Value In Array Randomized Array Ray Cast Hit Normal Ray Cast Hit Player Ray Cast Hit Position Remove From Array Right Round To Integer Score Of Server Load Server Load Average Server Load Peak Sine From Degrees Sine From Radians Slot Of Sorted Array Spawn Points Speed Of Speed Of In Direction Square Root String String Contains String Length String Replace String Slice String Split Subtract Tangent From Degrees Tangent From Radians Team Of Team Score Text Count Throttle Of Total Time Elapsed True Ultimate Charge Percent Up Update Every Frame Value In Array Vector Vector Towards Velocity Of Vertical Angle From Direction Vertical Angle Towards Vertical Facing Angle Of Vertical Speed Of Victim Weapon Workshop Setting Combo Workshop Setting Hero Workshop Setting Integer Workshop Setting Real Workshop Setting Toggle World Vector Of X Component Of Y Component Of Z Component Of

A Workshopper's Guide to the Vector Last updated June 11, 2023

What is a Vector?

A vector is a set of 3 numbers: X, Y, and Z, that can represent a position or a direction. To get the X, Y, or Z as a single number, use the values X Component Of, Y Component Of, and Z Component Of.

Vectors as Locations

A vector can represent a location that is either relative to the world (global), or relative to a player's location and facing direction (local). When a vector is used as a location, the Y component represents the vertical height of the location, and the X and Z components represent where the location is on the horizontal plane.

Note that using the Live Capture (Camera) button to generate a location vector selects the player's current eye location (about 1.5m above the foot position of the player).

Global Locations

Global locations are fixed to the map and do not change. To obtain the global location of an entity or player at any time, one can use Position Of.

Local Locations

Global locations can be transformed to be defined relative to a player's location and facing direction via the value Local Vector Of. In local coordinates, the player’s foot position is always [0, 0, 0]. The X becomes how far left or right of the player the position is, relative to the horizontal direction the player is facing, with positive X being to the left. The Y becomes how far up or down the position is relative to the player, with positive Y being up. Finally, the Z becomes how far forward or backwards the position is relative to where the player is and which horizontal direction they are facing, with positive Z being forward. If that’s confusing, hopefully an example will help. Let’s say that we have a location at (105, 16, -104) and a player at (100, 10, -100) facing towards positive Z (facing direction [0, 0, 1]). If we use Local Vector Of to transform our location to local coordinates relative to the player, the X will be 5, since the location is 5 meters to the left of our player. The Y will be 6, because the location is 6 meters above our player, and the Z will be -4, because the location is 4 meters behind the player, making the final result [5, 6, -4]. When translating a location to local coordinates, the Transformation mode should be set to Rotation and Translation for correct results. Local locations are useful for keeping something in a certain position relative to a given player (for example, an effect that follows a player).

Vectors as Directions

Vectors can also represent directions, either the direction a player is facing, or the direction from one location to another. Vectors which represent directions are always unit length, which means the length of the vector is equal to 1. This makes it easier to work with in math. (See Normalization)

Player Facing Direction

When a vector is representing the direction a player is facing, the Y component (second number) of the vector represents how far up or down the player is looking, with -1.0 being looking straight down and 1.0 looking straight up. The X and Z components will represent how far along the respective world axes the player is looking.

A-to-B Direction

A vector can also represent the direction from Point A to Point B. To obtain a direction from Point A to Point B, take the location of Point B and subtract the location of Point A (see Vector Math > Addition and Subtraction below).

Working With Vectors

Defining vectors

Here’s a vector that we have labelled u.

The vector u begins at point A and ends at point B. We can see that u has a length, the distance from A to B. We can also see that u has a direction, the direction from A to B. This is essentially what a vector is.

More formally, we can say that a vector is a geometric object with both magnitude and direction. Magnitude is interchangeable with length in this context. We’ll use magnitude moving forward.

Note that the position of a standard vector isn’t important. That is, we could move u anywhere in our diagram and as long as we preserved its magnitude and direction it wouldn’t matter.

Let’s define some concepts, which we’ll use to simplify following topics:

  • As you may have noticed, we will denote vectors in bold lower-case and points in regular upper-case.
  • We will denote the length of u by writing |u|.
  • If u is a vector from A to B, we can also write it as AB. Note that this is different from BA, which would be the vector from B to A. Direction matters!
  • If u is a vector from A to B, we say that A is the tail of u and B is the head of u.
  • A vector with no magnitude is called the zero vector and is denoted by O. The zero vector also has no direction.

Defining position vectors

Let’s move into a 3D space to replicate Overwatch’s environment. Here’s a different u.

Firstly, the x axis is red, the y axis is green and the z axis is blue.

A position vector in 3D space is a vector from O = (0, 0, 0) to some point P. By definition, all position vectors start from O. A position vector can therefore be identified just by the coordinates of its destination point P.

In this case, we have a position vector u that we could write as OP or just as the coordinates of P, that is u = (-1, 2, 3).

In other words, the notation u = (x, y, z) is shorthand for a position vector u from O = (0, 0, 0) to the point at (x, y, z).

In the previous section we established that position isn’t important for standard vectors. However, position is important for position vectors - we can’t just move u because it’s fixed between coordinates O and P. We will soon see the significance of this.

For now, let’s define some more notation.

  • The point O = (0, 0, 0) is called the origin.
  • Suppose we have a vector u = (1, 2, 3).
  • The x component of u is 1.
  • The y component of u is 2.
  • The z component of u is 3.

All global vectors in the Overwatch workshop are position vectors. We can now understand why the Vector value takes three arguments - they correspond to the X, Y and Z components of the vector.

Furthermore the values X Component Of, Y Component Of, and Z Component Of each take one argument that’s a vector and returns the relevant component.

Defining scalars

A scalar is essentially just another name for a regular number. For example, suppose we have a vector u = (-2, 1.5, π). Then u is a vector and not a scalar, but each of its components is a scalar.

Multiplying vectors by scalars

Suppose we have some scalar λ (lambda) and some vector u. Then multiplying u by λ scales the magnitude of u by λ.

If λ is negative, the direction of u is flipped and then λ scales the magnitude of u as if λ were positive.

The following diagram illustrates this concept with standard vectors.

Note that -u gives u in the opposite direction.

Also note that two vectors u and v are parallel, or rather are in the same direction forwards or backwards, when there exists a scalar λ such that u = λv.

But what happens if we multiply a vector with another vector? There are multiple ways to do this, which we will explore later.

Addition and subtraction

We will return to standard vectors to begin talking about addition and subtraction. Here are two vectors u and v.

We can add u to v by moving v so that the tail of v touches the head of u. That is, so that C is on B. Then u + v is the vector from A to D.

We can draw v + u to observe that it produces the same vector.

Hence we can conclude that the addition of vectors produces another vector and is commutative, that is u + v = v + u.

Note that adding or subtracting a scalar to a vector, or the other way around, is an undefined operation. Don’t do it and don’t worry about it!

Calculating magnitude

The magnitude of a vector is a scalar which can be interpreted as the vector’s “length” or “size”. For instance, the magnitude of a player’s velocity vector is a scalar which represents the player’s speed. To get a vector’s magnitude, use the Magnitude Of value.

Normalization

While every vector possesses both magnitude and direction, oftentimes only the direction is relevant to the user. In cases such as these, it can be useful to set the vector’s magnitude equal to 1 while preserving its direction. This process is called normalization, and the resulting vector is called a unit vector.

To normalize a vector, use the Normalize value.

Join the Workshop.codes Discord