Force Effect Framework
Last updated
Last updated
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!
PhysKit's Force Effect framework is a simple structure that allows the designer to tailor physical environments in editor for quick iteration.
You can use Force Effects to create global or localized forces the system is composed of three basic parts
These describe how a force is applied to a body and go beyond Unity's "mode" concept.
For example a "wind force" would likely have a degree of turbulence adjusting its direction and would apply its force based on quadratic drag ... that is an object with more drag would experience more wind force than an object with less drag.
Gravity in contrast to wind applies a constant acceleration force toward its point of origin, so with a single point of origin we can simulate spherical gravity while an origin direction would allow us to simulate localized gravity similar to a body on a planet which brings us nicely into Force Effect Sources.
You can easily create custom Force Effects using the ForceEffect base class, see the Force Effects article for more information.
TIP
Force Effect Sources can apply multiple Force Effects, mix and match
A Force Effect Source describes the origin and strength of a force and allows us to declare this force global or not and to limit the effects to linear and or angular.
Global Force Effect Sources are managed by the static ForceEffects API and are read by all valid receivers.
Local (non-global) sources only effect receivers that have triggered them.
How you decide what sources are triggered is up to you though we have built in a system using Unity's Collider Is Trigger features.
Receivers will test On Trigger Enter and On Trigger Exit to determine if they have entered or exited the trigger collider of a source and will activate that source on themselves is so and if not ignored.
We have two types of built in sources, and you can easily create custom sources ... see the Force Effect Source article for more information
A Force Effect Receiver is simply the interface point for the system to operate on a body. When added to a Rigidbody it will automatically add a Physics Data component providing enhanced physical information about the subject.
The recieiver componenet can be used to adjust what sources can effect this body and in what way as well as the sensitivity of this body to forces.