In this project, I implemented a system for simulation of spring - mass - damper systems in C# for Unity Engine. This project was created to play around with control algorithms before an exam in control theory.
- PhysicsManager.cs holds a description of a spring-mass-damper system and can apply a Runge Kutta update on the system.
- PhysicsPart.cs defines a point mass. This can be attached to a Unity GameObject to designate the object controllable by the custom physics system.
- SpringDamperEffector.cs defines a connection between two parts with a spring (with a relaxed distance and a spring constant) and a damper (with a damping constant).
- ExternalForceEffector.cs applies a gravitational force to an object controlled by the custom physics system.
- PID.cs implements a PID controller logic that relates an output linearly to the input, the (approximated) integral of the input, and the derivative of the input. Through an ExternalForceEffector, a controller can influence its environment.
- PendulumController.cs is a controller for a inverted pendulum that is mounted on a sled that can only move left or right to keep the pendulum upright.
Please note that this is not a finished product by any means. To execute the code, set the code up as the Assets folder of a Unity Engine project.