New account registrations are disabed. This website is now an archive. Read more here.

Unity    Posted December 5, 2014 by drago2308

Drago’s Advanced Camera Script

Introduction

This is an advanced camera script that follows the selected target and also offers complete control over the camera in real time though the use of triggers.

Features

– Simple to implement
– Heavy commenting for those who would like to learn though reading my code
– Custom Prefabs for easy control of camera
– Highly customizable, as many variables can be changed in the inspector
– SHAKING

The Code

Downloads

dragos-advanced-camera-script-v1-26643.zip

15.76KB, .zip

Download

dragos-adavanced-camera-script-26643.zip

13.60KB, .zip

Download

License Terms

Attribution 3.0 Unported - You must attribute the work in the manner specified by the author or licensor. Commerical use allowed.

Frequently Asked Questions

None of yet, Please tell me if you find any bugs!

 

(Always download the largest file when updating)

Instructions

First copy the contents of the zip (demo) file into your project (drag the files into the project folder).

 

1. Drag the "Main Camera" Prefab into the scene (Anywhere is fine, the script automatically places the camera) And select the target (usually the player).
2. Play the game and test and adjust the height and distance to your liking, (make sure you remember the number as when you stop the game the variable numbers will not be saved and you will need to enter them in Scene mode before they will be permanent) The offset and Angle can also be set if you desire.
3. Drag any of the Trigger prefabs, such as the offset trigger (named "Camera Offset") into the scene and size and place it where you would like the area of effect to happen. ( The box collider size can be changed in the inspector if needed) must enter the desired values of course!.
4. Play the game and have the player run into the "trigger area" to test the effect. (player must have a collider attached to them for the "collision" to occur)

 

Experiment have fun,

 

For those who don’t want to use the prefab you can attach the script above to the main camera of your scene 😛 if you know how to do that you can figure out the rest quite easily *grin*.

Author Notes

One note, all three triggers can be placed in the same area and each effect will be taken into account without an error, however if 2 or more of the same trigger overlaps you will experience camera twitches.

 

The offset trigger and the shake trigger may not be compatible while the offset trigger is in transition, please refrain from using these two in quick succession, however they can be used within another. Just be careful with them if you don’t your game to have camera bugs.

Compatibility

Other Camera scripts are bound to have errors with this, kinda obvious here.

Version History

v1.0 – initial build
v1.1 – smooth transition added
v1.2 – bug fixes and streamlining of code
v1.3 – SHAKING! (starting implementation new thinking algorithm)

Credits & Thanks

It would be nice if you credited me for use of this code if you use it.

 

Thanks to Documentation!

Comments (6)

  • [quote]Wait a minute….did you take this out from your game?[/quote]
    I was planning to release it out to everyone, It's definitely not a thing worth paying for, There are a few things that our game will offer that this script cant handle without extra setting up in the scene. but the character controller will always be in the game (that took me ages!) for the same reason. plus the camera is an essential part of a game so why not allow people to easily implement their own.

  • [quote]OH yea you can do block comments also if you didnt know.[/quote]
    ja I know, just prefer not to, I'm weird like that
    [quote]Should also use booleans so they can just check a box for experimental features[/quote]
    The experimental code is mostly broken(it won't work, hence why its commented out), so there is no reason to activate it unless you want it to die.
    I keep it in there to remind myself to make it work later on.
    Thanks for the feedback, I'll reformat the code to include block comments if you really want it to be. 😀

Leave a Reply

drago2308

  • Posted about 10 years ago

  • Engine
    Unity
  • Category
    System Enhancements
  • License
    Attribution 3.0 Unported
  • Version
    1.3

Stats

1,534 views

6 comments

Tags

n-a