I spent this entire week creating a script that allows for creation of dynamic objects / effects
Initially this was meant to ease the creation of a avoidance type situations (like a boss) but many of the functions can be used to create other basic effects without the need to dig up the complicated code each time you create a new script.
Most of the functions in the script are below (if your into what is actually in the script)
Pretty much every coroutine below has multiple variables that change how it works
- When the coroutine is triggered
- Delay of individual object manipulation (creation / destruction)
- Size / Speed / Direction / Etc
The following "shapes" are created by a set of subobjects (ie a circle made from 30 apples of a certain radius)
The subobjects are added to a list for later manipulation in other functions
Just for note, a subobject can be ANY prefab. You could create a line from point A to point B made out of blocks / platforms / deadly apples / or even monsters that have their own scripts attached to them.
CreateCircle - Creates a circle of a certain radius made from X objects. (can do semi circles or parts of circles)
CreateSquare - Creates a square of a certain X/Y width made from X objects
CreateTriangle - Creates a triangle of a certain X/Y width made from X objects.
CreateLineInDirection - A line of X objects is created of a certain length in a certain direction
CreateLineToTarget - Creates a line of X objects from this object to the targeted object
CreateLineToPlayer - Creates a line of X objects from this object to the players current position
-- The following are manipluation functions that effect the parent object --
C_RotateTwordsObject - Make this object "face" another target location (instantly or overtime or forever)
C_RotateToDegree - Sets the object to X degrees (instantly or overtime)
C_RotateObject - Rotates in a certain direction X degrees or Forever rotation (instantly or overtime)
C_StopRotation - Stops all rotations
C_MoveInDirection - Moves object in a certain Vector3 direction
C_MoveToPosition - Move this object to a certain point
C_LaunchAtPosition - Throws the object in the direction of the targeted position
C_LaunchAtPlayer - Throws the object in the direction of the player
C_StopMovement - Stops all movement
-- Object Effects --
C_ChangeScale - Makes the overall creation Bigger/Smaller. Can keep the subobjects the same size or grow / shrink with the parent
C_WaveEffectWhole - Creates a wave effect in X/Y direction for the child objects
C_WaveEffectObject - Creates a wave effect in X/Y direction in one object
C_StopWaveEffect - Stops wave effects
C_MorphToSquare - Morphs the current collection of objects into a square shape over time
C_MorphToCircle - Morphs the current collection of objects into a circle shape over time
-- These are finishers that end up destroying the object --
C_BreakToPosition - Breaks apart the entire object and launches them at a target location
C_BreakToPlayer - Breaks apart the entire object and launches them at the players location
C_BreakRandomly - Breaks apart the entire object and launches them randomly in every direction
C_BreakCircleBurst - Breaks apart the entire object and creates a circle burst at every subobject
-- These are one shot objects that are non manipulatable by other functions --
C_FollowPlayer - Creates a single object that follows the player until the object dies
C_ShootDirection - Shoot X objects in a certain Vector3 direction
C_ShootPosition - Shoot X objects at a certain target location
C_ShootPlayer - Shoot X objects at the players location
C_SprayInDirection - Creates a set spray of objects in a certain general direction (like a fountain)
C_ShootFromRightScreen - Random objects come from off the screen
C_ShootFromTopScreen - Random objects come from the top of the screen
C_CircleBurst - A single circle burst at target location.
Circle burst = A set of objects at a point that expand rapidly in the shape of a circle.
Using the new script, these are the commands I used in creation of the avoidance screen (I attached this script to 2 empty objects on the scene).
The variable TEST is just a location in the scene. The first variable in each call is the time delay of the action.
Its pretty simple to see what is supposed to happen at each step. This is the point of this weeks script.
StartCoroutine (CreateLineInDirection (1, 0.1f, 12, new Vector2(-1, 0), 4));
StartCoroutine (C_WaveEffectWhole(2, 0,0,0.5f,1));
StartCoroutine (C_StopWaveEffect (7));
StartCoroutine (C_MoveToPosition(7, TEST, 4));
StartCoroutine (C_MorphToCircle(7, 1, 1, 0f, 4));
StartCoroutine (C_RotateToDegree(9, 1f, 90, false));
StartCoroutine (C_ShootFromTopScreen(11, 10, 0.5f, 2));
StartCoroutine (C_ChangeScale(11, 2f, 1, true));
StartCoroutine (C_ChangeScale(13, 1f, 1, true));
StartCoroutine (C_ChangeScale(15, 2f, 1, false));
StartCoroutine (C_ChangeScale(17, 1f, 1, false));
StartCoroutine (C_RotateObject(19, -1f, 0, true));
StartCoroutine (C_MoveInDirection(20, new Vector2(0,-1), 1));
StartCoroutine(C_ShootPlayer (20, 10, 0.2f, 2));
StartCoroutine (C_StopMovement(22f));
StartCoroutine (C_StopRotation(23f));
StartCoroutine (C_RotateToDegree(23.1f, -4f, 0, true));
StartCoroutine (C_MorphToSquare(23.5f, 1f, 1f, 2));
StartCoroutine (C_BreakCircleBurst(25f, 10 ,0.5f));
StartCoroutine(C_SprayInDirection (33, 45, new Vector2(0f,1), 0.1f, 5));
StartCoroutine (C_CircleBurst(40.2f, TEST, 10, 2));
StartCoroutine (C_CircleBurst(41.3f, TEST, 20, 2));
StartCoroutine (C_CircleBurst(42.4f, TEST, 30, 2));
StartCoroutine (C_CircleBurst(43.5f, TEST, 40, 2));
StartCoroutine (EnableExit(45));