Collisions - earok/scorpion-editor-demos GitHub Wiki

Actor Collisions

All registered collisions must have at least one projectile or player. Both can be projectiles and both can be players also.

Any actor can be set to the projectile class. It doesn't need to necessarily be something that's literally a projectile - in a game where enemy tanks can collide into each other, setting them both as projectiles might be recommended.

Any actor can collide with a player. Even if it's a literal projectile, if it only damages the player and not other actors it's worth considering leaving Projectile turned off to improve performance.

Actors vs Players | Players vs Actors

  • On Collide With Player: Set on the ACTOR to trigger when that actor collides with the player or vice versa.

Actors vs Projectiles | Projectiles vs Actors

  • On Hit By Projectile: Set on the ACTOR to trigger when that actor collides with a projectile or vice versa.

Players vs Projectiles | Projectiles vs Players

  • On Collide With Player: Set on the PROJECTILE to trigger when that projectile collides with the player or vice versa.
  • On Hit By Projectile: Set on the PLAYER to trigger when that actor collides with a projectile or vice versa.

Players vs Player

  • On Collide With Player: Set on either PLAYER to trigger when that player collides with another player.

At one player in a collision will impersonate an actor. For example -

//Give point to whatever player is higher when two actors collide

if player_y > actor_y
    //The "player" is higher so award point to that controller
    set AwardedToPlayer = player_controller
else
    //The "actor" is higher so award point to that controller
    set AwardedToPlayer = actor_controller
end

if AwardedToPlayer == 1
    set Player1Points = Player1Points + 1
else
    set Player2Points = Player2Points + 1
endif

Projectiles vs Projectiles

  • On Hit By Projectile: Set on the either PROJECTILE to trigger when that actor collides with a projectile.

At one projectile in a collision will impersonate an actor. For example -

//Destroy whatever projectile is lower

if projectile_y > actor_y
    //The "projectile" is higher so destroy the other one
    actortype none
else
    //The "actor" is higher so destroy the other one
    projectiletype none
end

Actor Melee

Like with collisions, all melee attacks must involve at least one player or projectile.

The area that can receive blows is, by default, the actor's normal collision box. Hurt boxes can be set in the animation window to handle special cases such as receiving damage on limbs.

The shape of melee attacks themselves is drawn in the animation tab.

Actor vs Player | Player vs Actor

  • On Melee AGAINST Player: Set on the ACTOR to register a collision when this actor performs a melee attack against the player.
  • On Melee BY Player: Set on the ACTOR to register a collision when this actor receives a melee attack by the player.

Actor vs Projectile | Projectile vs Actor

  • On Melee AGAINST Projectile: Set on the ACTOR to register a collision when this actor performs a melee attack against the Projectile.
  • On Melee BY Projectile: Set on the ACTOR to register a collision when this actor receives a melee attack by the Projectile.

Player vs Player

  • On Melee AGAINST Player: Set on the PLAYER to register a collision when this player performs a melee attack against another player.
  • On Melee BY Player: Set on the PLAYER to register a collision when this player receives a melee attack by another player.

Actor impersonation applies here as well so at least one player will appear to be an actor.

Since these essentially mean the same thing from different perspectives, you may not need to set both.

Projectile vs Projectile

  • On Melee AGAINST Projectile: Set on the PROJECTILE to register a collision when this projectile performs a melee attack against another projectile.
  • On Melee BY Player: Set on the PROJECTILE to register a collision when this projectile receives a melee attack by another projectile.

Actor impersonation applies here as well so at least one projectile will appear to be an actor.

Since these essentially mean the same thing from different perspectives, you may not need to set both.

Wall Tile Collisions

Most actors can collide with wall tiles.

Actors can be set to have different collision events for colliding into a wall from four different directions. Scorpion offers a number of built in collision handlers but you can also implement your own.

Note that when implementing a custom wall collision, you may want to set "Handle_Collision" to true or false to tell the game engine whether or not the actor should still be blocked by the wall.

The "Simple Wall Coll" flag can be used to simplify wall collisions to be much faster and less accurate.

Block Collisions

The Block Collider is a special actor flag that registers not only solid collisions with blocks, but also trigger special codeblock actions.

  • On Player Collide: If the Block Collider is a player, this event will trigger on collision.
  • On Block Collider Collision: If the Block Collider is NOT a player, this event will trigger on collision.
  • On Melee: If the block is hit by a melee strike, this event will trigger.

There are also two custom overrides for "Player" and "Block Collider". For example, you may decide that a crate cannot be passed by players, but can be passed by bullets. In that case, you would say that the bullets are all "Block Colliders" and the override is set to none.

Note that these events will trigger every frame if a block collider is standing on them with a Platformer type, as gravity will repeatedly trigger these collisions.

Block Overlapping

Block Overlapper is a special flag only for players that enables this block event

  • On Player Overlap: For every frame that the player is standing on this block, this event will run.

Map Event Collisions

The map tab allows custom collision rectangles to be drawn which are triggered by overlapping those rectangles in the level.

They can only be triggered by players, and players can only trigger one at a time.

  • EventTag: Tag to uniquely identify this event in codeblocks.
  • TeleportId: Id used to teleport to this event from anywhere in the game, including other levels.
  • Pushout: The player is forced to be pushed out of the event in this direction. Useful for conveyor belts.
  • Once Only: Never trigger this collision more than once.
  • Enable Var: Only trigger this event if this variable is different to zero.
  • On Enter: Triggered when the player enters the event.
  • On Exit: Triggered when the player leaves the event.
  • On Interact: Triggered when the player activates the fire button within the event.
  • On Stay: Triggered every frame that the player is still standing in the event.
  • Is Camera Zone: Changes the level's camera box so that the camera will not leave this event zone (until the player enters another camera zone for example).