Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lopespm/unity-camera-multi-target
Unity library to dynamically keep multiple objects in camera view
https://github.com/lopespm/unity-camera-multi-target
Last synced: 2 months ago
JSON representation
Unity library to dynamically keep multiple objects in camera view
- Host: GitHub
- URL: https://github.com/lopespm/unity-camera-multi-target
- Owner: lopespm
- License: apache-2.0
- Created: 2018-12-26T00:27:56.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-08T13:06:51.000Z (about 5 years ago)
- Last Synced: 2024-08-02T05:21:07.085Z (5 months ago)
- Language: C#
- Homepage:
- Size: 1.44 MB
- Stars: 209
- Watchers: 11
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-opensource-unity - Dynamic Multi Target Camera for Unity - Concise Unity library which dynamically keeps a set of objects (e.g. players and important objects) in view. (Open Source Packages / Camera)
- awesome-unity3d - Dynamic Multi Target Camera for Unity - Concise Unity library which dynamically keeps a set of objects (e.g. players and important objects) in view. (Open Source Repositories / Camera)
- awesome-unity-open-source-on-github - unity-camera-multi-target - Unity library to dynamically keep multiple objects in camera view (Camera)
README
# Dynamic Multi Target Camera for Unity
Concise Unity library which dynamically keeps a set of objects (e.g. players and important objects) in view, a common problem for a wide range of games.
The library was originally developed for, and used by [Survival Ball](https://survivalball.com/), a game with a heavy shared screen local co-op component, requiring the camera to dynamically keep many key elements in view. More information about the library's inner workings and underlying math in the related [blog article](https://lopespm.github.io/libraries/games/2018/12/27/camera-multi-target.html).
[](https://assetstore.unity.com/packages/tools/camera/camera-multi-target-dynamic-135922)
[](https://www.youtube.com/watch?v=In3eVapQ5mk)
## Install
### From Unity's Asset Store
Available at https://assetstore.unity.com/packages/tools/camera/camera-multi-target-dynamic-135922. Via Unity Editor, download and import the CameraMultiTarget folder into your project.
### By importing CameraMultiTarget.unitypackage
The pre-built package can be downloaded from the repository's releases [here](https://github.com/lopespm/unity-camera-multi-target/releases/latest). After downloading the package, import it to your project via Unity Editor: *Assets -> Import Package -> Custom Package..*.
### Or by cloning this repository
#### Clone entire repository (git)
This repository contains the complete Unity project which includes the library and an example usage scene. After you clone the entire repository using git, copy the *Assets/CameraMultiTarget* folder to your project
git clone https://github.com/lopespm/unity-camera-multi-target.git
#### Checkout specific features (SVN)
Since cloning a specific folder can be a quite convoluted process via git, you can checkout the *Assets/CameraMultiTarget* folder directly to your project using SVN:
cd
svn checkout https://github.com/lopespm/unity-camera-multi-target/trunk/Assets/CameraMultiTarget Assets/CameraMultiTargetOr if you wish to only install the library without the example scene:
cd
svn checkout https://github.com/lopespm/unity-camera-multi-target/trunk/Assets/CameraMultiTarget/Library Assets/CameraMultiTarget/Library## Usage
Add the [`CameraMultiTarget`](Assets/CameraMultiTarget/Library/CameraMultiTarget.cs) component to a camera and then you can programatically set which game objects the camera will track via the component's [`SetTargets(GameObject[] targets)`](Assets/CameraMultiTarget/Library/CameraMultiTarget.cs#L23) method.
For example, you can set the targets in your game controller component (if you choose to have one), like the following:
public class ExampleGameController : MonoBehaviour
{
public CameraMultiTarget cameraMultiTarget;
private void Start() {
var targets = new List();
targets.Add(CreateTarget());
targets.Add(CreateTarget());
targets.Add(CreateTarget());
cameraMultiTarget.SetTargets(targets.ToArray());
}private GameObject CreateTarget() {
GameObject target = GameObject.CreatePrimitive(PrimitiveType.Capsule);
target.transform.position = Random.insideUnitSphere * 10f;
return target;
}
}## Example Scene
An example scene of the library's usage is included in this repository and in the pre-built package located in the repository's releases.
## Games using Dynamic Multi Target Camera
- [Survival Ball](https://survivalball.com/)
*Did you develop, or know about, a game using this library? Add it here via [pull request](https://github.com/lopespm/unity-camera-multi-target/pulls)*