This commit is contained in:
Felix Klenner 2023-11-30 11:50:57 +01:00
parent 1abac4460d
commit 0f4911a96e

34
README.md Normal file
View file

@ -0,0 +1,34 @@
# Cable Joints implementation in Unity
### Running:
- Load project in Unity
- Select a scene from the file explorer in "Assets > Scenes"
- Enable Gizmos using the button in the top right of the game preview
- Press the play button
### Code Structure
| File | Description|
|------------------------------------------------------------| -|
| [CableJointsAlgorithm.cs](Assets/CableJointsAlgorithm.cs) | Main Algorithm Implementation|
| [Controller.cs](Assets/Controller.cs) | Sets up the scene, creates Unity Game Objects|
| [RollerProperties.cs](Assets/RollerProperties.cs) | Contains properties for each part of the Cable|
| [Extensions.cs](Assets/Extensions.cs) | Useful extension methods|
### Creating a scene:
An effort was made to simplify creation of new scenes as much as possible and create most required objects in code instead.
- Create a new scene in unity
- Add the controller component to any object (e.g. the Main Camera)
- Add rollers using Right click > 2D Object > Sprites > Circle
- Other shapes can be added using the same menu
- Add the RollerProperties Component to all objects which should be connected by the cable and adjust the settings:
- Start: set for one of the ends of the cable
- Clockwise: determines the side the cable is running around the object
- Link To: Select the next game object the cable should be connected to
- Movement: Rotatable and Powered should only be used for circles and represent rollers. Fixed and Free can be used for any shape
- Use fixed attachment point: If set to true the object is not viewed as a roller, but a point attachment instead (e.g. weights)
- Objects not connected by cable (e.g. Floor) can be created by adding an sprite with a collider.
- Mass is calculated based on area
- Press 'T', to toggle powered wheels on and off.