Physical Connections to the Player

This slightly more advanced tutorial demonstrates how to create physical connections to the player, via an Eval block, to allow flight.

Simple Flight Spell
Earth magic in CodeSpells is centered around creating physical connections to the world and applying forces to objects. These forces can move or rotate an object in any direction. The typical way to create a physical connection, in which an object is pulled along wherever a spell orb goes, is by using the "Elastic Connection" block in the OnHit event of your spell. However, through a simple Eval script it is also possible to create a physical connection directly to a player.

This spell does the following things:
 * When Created:
 * Point the Spell Orb straight upwards and set its speed to slow.
 * Execute an Eval script to create a physical connection (also called and elastic connection) to the shooter of the spell.
 * The connection is actually required to be a collider, rather than an object by the way the game is designed by the developers.
 * When activated:
 * Destroy the orb, causing the player to lose the connection to the orb and return to normal.

Advanced Version
This spell is a little bit more advanced version of Simple Flight. It allows a player to hover upwards for a desired length of time, then activate to fly in whatever direction the player is currently looking. When created and active, it cycles through 3 actions The eval script for rotating the player is this: orb.transform.rotation = Quaternion.LookRotation(orb.shooter.GetPlayerLookDirection.direction, orb.shooter.transform.up);
 * Start in the "up" direction, with the spell orb moving upwards and pulling the player with it.
 * First activate: speed up the orb to medium, change the rotation of the orb so it points in the same direction as the player is looking, the change direction to "forward"
 * Next activate: destroy the orb and drop the physical connection to the player, causing them to fall.