Advanced Camera Follow

In previous page you have my contact information, so if you have any problem with this asset let me know, I'll help you. ______________________________________

CONTENTS OF THIS DOCUMENTATION

A. WHAT THIS ASSET GIVES YOU B. CONTENT C. HOW TO USE (TWO EASY WAYS OF USING THIS ASSET) D. VARIABLES IN THE INSPECTOR (Cam Follow) E. VARIABLES IN CAMERA SHAKE F. INTEGRATION WITH 3RD PARTY SCRIPTS G. DEMO H. LINKS I. CONTACT INFO __________________________________________

A. WHAT THIS ASSET GIVES YOU

In addition to the things "Simple camera follow" gives you: - Making your camera following a target - Adjust the "laziness" (how slowly the camera will follow the target, giving it more space) - Option of look at the target (camera will tilt to look at the target, displaying it always at the center of the screen) ..."Advanced Cam Follow" offers you: - Multi target: You can specify as many targets as you want. Your camera will keep all of them on the screen. - Limits: You can set a square (and modify it at runtime if you want), so the camera will stay always inside, so the edges of your map will remain at the edge of the screen. - Real-time adaptation to any screen size, any aspect-ratio and any field of view you set on your camera. - You can set a minimum distance, so your camera doesn't come too close of targets - You can set a general margin (distance from the farthest targets and screen edges) - It will consider volumes, not just the center of the targets. ...And camera shakes! You can trigger camera shakes of different magnitudes and durations. You can even specify on which axes the rotation will occur. If in some point you need something more advanced, look for "Cam Follow Pro" which gives you the possibility of (on top of everything mentioned before) defining fluid zoom zones, and polygonal bounds, for more complex levels. __________________________________________

B. CONTENT

Demo aside, this package contains: 1 prefab: "Camera with AdvancedCamFollow" 3 scripts: - dg_advancedCamFollow.cs - dg_cameraShake.cs - dg_shakeInspector.cs You can ignore the 3rd script, you even can delete it, it's not essential. It only brings to the inspector 3 buttons for testing the Camera Shakes. It can be useful in developing stage. __________________________________________

C. TWO EASY WAYS OF USING THIS ASSET

a) you can add to your current camera the two main scripts (dg_advancedCamFollow and dg_cameraShake, located in /Scripts). If you want to use the "limits" function, you'll also require adding a box collider to the camera (as a trigger) b) or you can replace your current camera with the prefab (located in /Prefabs) which already contains the scripts and the box collider, Once you have dg_advancedCamFollow attached, remember to tell who (or what) it should follow, dragging each target to the "Targets" variable. Then you can experiment with its variables, even in play mode. Keep in mind that the demo keys working in the Demo scene (1, 2, 3 for presets, I, O, P, for shake, R to reposition) work only in the Demo scene. They're catched in the scripts that controls the players. The scripts to be attached to the camera don't capture any keys. __________________________________________

D. VARIABLES IN dg_advancedCamFollow

- Targets (Transform[]): Array of each gameobject to follow. It should always be one at least. - Laziness (float): How slowly the camera will follow the targets. If there's only one target, it can be said: The lower this value, the more centered in screen the target will stay, and camera will follow every move the target does. The higher this value is, the less the target will remain on the center of screen, and the camera will let the target move more freely. If there're multiple targets, the same applies to the center of them. - Min Distance (float): Useful to prevent your camera coming too close of targets. It represent the minimum Z value (absolute) the camera position can have. For example, if "min distance" is 10, the Z value of camera position will never go above -10. - Use limits (bool): If checked, it will force the camera to stay always inside a squared area, so the edges of your map will remain at the edge of the screen. The squared area is dictated by a Box Collider (marked as trigger), a component of the camera. If "use limits" is unchecked, the box collider is not required. - Follow Targets Center (bool): Camera will tilt to look at the targets. If this option is checked but "laziness" is very low (like 1), it won't produce any effect. You should combine this option with a high "laziness" (more than 10 is recommended). - Margin: Minimum distance between the farthest targets and screen edges (considering their volume) - General offset (Vector3): A general offset to be applied. Use it with caution (meaning with a higher "margin" value), it may provoke the targets to go off screen. __________________________________________

E. VARIABLES IN dg_cameraShake

- Managed Externally (bool): If true, the script won't apply any rotation by itself. In other words, the Update() method won't call the ApplyShake() method, so other script (like dg_advancedCamFollow) can execute it when it's convenient. For example, if "follow targets center" is checked and the dg_cameraShake script is attached to the camera, both scripts would attempt to rotate the camera. In this case, dg_advancedCamFollow will call the public ApplyShake() method right after the rotation for "follow targets center" is made, before rendering, so the second rotations (the shake) will be applied on top to first ones, resulting on very smooth shakes. Keep in mind that dg_advancedCamFollow will automatically judge if this is the case (whether the "follow targets center" is checked and the dg_cameraShake script is attached to the camera), and will automatically set "Managed Externally" to true. ...So why this variable remains public? So it can be manually checked if another script is managing rotations of the camera. Instructions below. - Axes to shake: - Shake_x (bool): Whether the X axis of camera should be affected by the shake - Shake_y (bool): Whether the Y axis of camera should be affected by the shake - Shake_z (bool): Whether the Z axis of camera should be affected by the shake - Duration: This number represents how much (/100) the magnitude of the shake will be multiplied by, in each frame. For example, Duration 99 means that each frame the magnitude will be multiplied by .99, producing a long shake. Duration 80 means that each frame the magnitude will be multiplied by 0.8, producing a short shake. __________________________________________

F. INTEGRATION WITH 3RD PARTY SCRIPTS

CAMERA SHAKE + OTHER ROTATION SCRIPT

Are you planning to use Camera Shake but using some other script that rotates the camera, like a character controller? Then you should follow this 3 steps: 1. Go to that other script 2. Add this line in the declaration area: dg_cameraShake shakeScript; 3. On the Start() method, add this line: shakeScript = Camera.main.GetComponent(); 4. Search where the rotation is made, and AFTER that, add this line: shakeScript.ApplyShake();

CAM FOLLOW + OTHER ROTATION SCRIPT

Are you planning to use Camera Shake but using some other script that rotates the camera, like a character controller, and you're planning to enable "Follow target center"? Well, that can't be done, you would be managing camera rotation twice and surely with different criterias. If you plan to rotate the camera with another script, you should leave "Follow target center" unchecked. __________________________________________

G. DEMO SCENE

This asset contains a demo scene that showcases its possibilities. To run it, just go to /Demo/Scenes folder, and double-click the scene inside and press play. Demo scene (not the asset itself) uses Text Mesh Pro, but Unity will offer to install it ("Import TMP Essentials"). __________________________________________

H. LINKS

This asset in the asset store More from this publisher (also here) __________________________________________

I. CONTACT INFO

If you need my assistance regarding this asset, feel free to contact me. Just be patient if I don't answer right away, give me 24hs before you feel abandoned :) Contact info in previous page