Chaotic Motion is a Unity asset that moves game objects and particles under the control of a chaotic attractor in 3D or 2D. A comprehensive library of 40 chaotic systems is available to choose from . The asset provides default values for all chaotic systems and allows the system parameters, time scale, physical scale and starting location to be adjusted. Make agents in your game move on a chaotic path, create chaotic targets or add mesmerizing chaotic particle effects to your game!
Chaotic Motion provides scenes that highlight how to use the asset.
|ChaoticMotion||Demonstrate a single game object moved by a Chaotic system with a ChaosTrail.|
|ChaoticParticles||Demonstrate a particle system evolved with ChaoticParticles.|
|Guard||Simple example of two "guards" moving on a plane under ChaoticMotion control|
|AllSystems||Show all systems in one scene with camera zoom, spin. Script shows how to instantiate ChaoticMotion via scripting.|
|MotionSlideshow||Slideshow of each system using ChaoticMotion|
|ParticlesBurstSlideshow||Slideshow of each system using a burst of particles.|
|ParticlesFastSlideshow||Slideshow of each system using continuously emitted particles|
Two key components provide the chaotic motion: ChaoticMotion and ChaoticParticles. ChaoticMotion is attached to a game object and controls its position. ChaoticParticles attaches to a game object with a particle system and takes control of the positions of the particles.
Chaotic Motion of a Game Object
To move a game object chaotically simply add the ChaoticMotion component to it. The inspector controls allow a chaos system to be selected. The chaos systems are named after the researcher who first discovered them, so it can initially seem to be a somewhat baffling list. Several scenes in the asset provide a slideshow of the systems for both objects and particles.
The ChaoticMotion component will move the attached game object in accordance with the Chaotic System selected in the inspector using the parameter set provided. By default the parameter set is “default (scaled)”. This parameter set is tuned to scale the resulting motion to fit in a box roughly 10 units per side. Different options are available via the inspector:
Selects the chaotic system to use for the motion of the game object. Different systems will result in different types of chaotic motion.
The evolution of the chaos system takes place in a “physics space” internal to the ChaoticMotion component and is then translated in “game space” by using the initial position of the game objects and the evolution scale. The range of the motion in physics space is dictated by the equations of the system and the specific parameters in use. In order to make these different systems easily usable in a game context – there is a “default (scaled)” parameter set that uses scale and offset parameters to provide chaotic motion within a 10x10x10 box. These parameters are explained below.
Tinkering with the system parameters and initial position will change the resulting path. If the object diverges to infinity the script will stop evolving the game object.
Shows the equations that define the chaos system selected. These may be useful when customizing parameters. It is not necessary to understand the equations to use the asset.
Sets of parameters are bundled together into selections in the parameter drop down. The default choice results in a “common” choice for parameters (meaning those typically used in research papers about the chaotic system). The scaled default adjusts the physics offset and scale to produce chaotic motion in a 10x10x10 box at the local origin.
Selecting custom allows the specific parameters in the chaos system to be altered. The parameters also allow for control of the offset of the origin of the physical system and its scale to be adjusted.
Adjusts the speed of the evolution of the system. A value of 1.0 runs the system as described by the equations in their natural timescale. Systems vary in how quickly they evolve at different points in the trajectory. Reducing the value to lower than 1 (but greater than zero) results in slower motion in the scene; increasing results in faster motion.
The motion defined by the equations can be scaled up or down before it is mapped to the scene co-ordinates. If the motion is to be restricted to e.g. X and Y, then setting the evolution scale of Z to 0 will accomplish this.
Chaotic particle motion can be created by attaching a ChaoticParticles component to a standard Unity particle system. The particle system configuration must:
- have zero velocity for the particles
- not render the particles as “stretched billboard”
The script will check for these conditions and log an error if they are detected.
The ChaoticParticles component takes control of the particle evolution, so parameters that adjust velocity and velocity over time will have no effect.
The Chaotic evolution is controlled by the inspector using are the same controls as the ChaoticMotion component. These are described above.
Chaos systems are by their nature very sensitive to the initial conditions at the start of evolution. Typically particle emission in a small region within the attractor produces interesting results, but feel free to experiment. In some cases particles will diverge to infinity and the script will stop evolving them.
The Unity TrailRenderer component is useful to show the path an object has taken. In some cases, its use with an object controlled by a ChaoticMotion script can result is a segmented appearance. This is because the trail renderer connects past positions with line segments and in regions where the object moves quickly, points in between are missed. The ChaosTrail component was designed to smooth out these segments.
The ChaosTrail script is typically attached to a child of the chaotic object. This allows the attributes to be varied independently. The ChaoticMotion component will detect any ChaosTrail components and update them during the physics calculations within a frame to maintain a smooth path behind the object. The parameters for ChaosTrail are:
Distance to be exceeded before a new point is added to the LineRenderer.
Maximum number of points in the trail.