Character Vault
Any Concept / Any System
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Script:Collision Detection

From Roll20 Wiki

Jump to: navigation, search
API ScriptAuthor: Brian
Version: 2.2
Last Modified: 2016-04-12
Code: Collision Detection
Dependencies: None
Conflicts: None

Collision Detection will watch for collisions between tokens and a subset of the paths on the player page. When an event occurs, some configurable behavior will be applied.


There are three configuration values. You may alter them to customize the script functionality:

  • Path Color – The script only considers paths of a specific color, allowing you to also use paths of other colors which your players will not collide with. By default, this is fuchsia; the color is specified as a hexadecimal web color, which you can see when selecting a color from the drawing interface. A path's fill color is ignored.
  • Layer – The script will only look at paths on the specified layer (map, objects, gmlayer, or walls). You can also set this value to "all" and paths on every layer will be considered.
  • Behavior – There are currently three different behaviors dictating how the script will act when a collision event occurs:
    • "Don't Move" – return the token to its starting position prior to the movement
    • "Warn Player" – sends a message to the token's controller warning that the token isn't supposed to be there
    • "Stop at Wall" – the token will be moved 1 pixel away from the wall it collided with

Any two behaviors can be combined except for "Don't Move" with "Stop at Wall".

Usage Notes

Currently, this script only considers polygons and polylines as "walls" to collide with, which means no freehand drawings or circles/ovals. Additionally, the math in the script does not handle paths which have been resized or rotated.

Tokens which can only be moved by the GM (no player is assigned to control it, and the token isn't linked to a character sheet which is assigned to any player) do not collide with walls. This will let the GM move things around at will. However, if the GM is assigned as the controlling player for a token, or if the token is linked to a character sheet which has the GM assigned as the controlling player, the token will collide with the walls.

The script will break if you go "warp speed" by holding down an arrow key to move, and the token passes through multiple walls before the script catches up. (If you drag a token through multiple walls, the script will collide at the first one.)

In most cases, the dynamic lighting will not update before the token's position is reset to the correct side of the wall (assuming a relevant behavior is set), meaning the player won't see what's on the other side (if the wall is on the DL layer or there's a similarly-positioned wall on the DL layer). However, sometimes the DL will update first, and the player will catch a glimpse of the other side.


v2.2 (2016-04-12)

  • Update globalconfig support

v2.1 (2016-03-09)

  • Update for one-click install

v2.0 (2015-01-08)

  • Release