A tool that prevents Actors from clipping into colliders. One common use case for a spring arm is to prevent cameras from becoming obstructed by walls.
Minimum supported Flax version: 1.5.
SpringArmDemo.mp4
For more details, see how to install a plugin in the Flax Engine documentation.
-
Create a
Pluginsfolder in your game's project directory and close this repository into it:<game-project>\Plugins\SpringArmPlugin -
Add reference to the SpringArmPlugin project in your game by modyfying your game's
<game-project>.flaxprojfile like this:
"References": [
{
"Name": "$(EnginePath)/Flax.flaxproj"
},
{
"Name": "$(ProjectPath)/Plugins/SpringArmPlugin/SpringArmPlugin.flaxproj"
}
]- If you want to access the SpringArmPlugin from your game's scripts, add this line of code in your game's
Game.Build.csfile in theSetupfunction:
public override void Setup(BuildOptions options)
{
base.Setup(options);
// Add the SpringArmPlugin to the private dependencies of the Game.
options.PrivateDependencies.Add("SpringArmPlugin");
}Since the plugin is written in C++, you'll also need to build the SpringArmPlugin project so that the C# glue is generated, if you plan on using the spring arm with C# scripts. To do so in Visual Studio, open a script in your project, and go to the Solution Explorer:
For easier access to the API, you can also reference the SpringArmPlugin namespace in your script:
using SpringArmPlugin;Now, the SpringArm plugin should be ready to go!
The SpringArm works by shooting a physics cast along its backwards direction. If the cast collides with anything, all of the arm's children are moved to the closest point away from the collision. The SpringArm is implemented as an Actor that can be added to the scene in the same way as any other Actor in Flax Engine. You can find it by right clicking your Scene window and going to New/Physics/Spring Arm or in the Toolbox window under the Physics tab. You can use the SpringArm like any other Actor in Flax:
SpringArm _springArm;
/// <inheritdoc/>
public override void OnStart()
{
_springArm = Actor.As<SpringArm>();
_springArm.ArmLength = 600;
}The entire API for the SpringArm is documented in XML.
This plugin and its source code are available under the Zlib liscence.
