GithubHelp home page GithubHelp logo

neuralnoise / unity-rts-camera Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evanhahn/unity-rts-camera

0.0 2.0 0.0 38 KB

A little script for RTS games in Unity. Abandoned. Add an issue if you want to take over!

License: MIT License

C# 100.00%

unity-rts-camera's Introduction

RTS camera for Unity

Attach this script to a camera and then you can use it RTS-style.

Note: I'm a Unity newbie, so I'm sorry if I don't know what I'm doing! Happy to accept pull requests.

Quick start

  1. Attach this script to a camera.

  2. Add "Mouse Look" and "Mouse Select" to your inputs. I recommend changing the default Fire1 and Fire2 for left and right mouse buttons.

  3. Make sure selectable objects have 3D colliders on them.

  4. For any selectable object, add the following code:

    void OnTriggerEnter(Collider other) {
       if (other.gameObject.name == "RTS Selection") {
         // This object has been selected; do stuff!
       }
    }
    
    void OnTriggerExit(Collider other) {
       if (other.gameObject.name == "RTS Selection") {
         // This object has been deselected; do stuff!
       }
    }

That's it!

For more usage, check out the demo.

Class RTSCamera

One RTSCamera should be attached to the main camera for your game.

Property Type Default Description
disablePanning bool false When true, the player cannot pan the camera.
disableSelect bool false When true, the player cannot select.
disableZoom bool false When true, the player cannot zoom.
selectColor Color Color.green The selection box drawn on-screen will be this color.
selectLineWidth float 2f The selection box drawn on-screen will have this line width.
maximumZoom float 1f Maximum zoom; minimum camera scale. (This value will be less than minimumZoom, which might seem backwards.)
minimumZoom float 20f Minimum zoom; maximum camera scale. (This value will be greater than maximumZoom, which might seem backwards.)
lookDamper float 5f Panning speed will be divided by this value. A higher number makes for slower panning.
selectionObjectName string "RTS Selection" When a selection happens, a trigger (a BoxCollider) will be dropped briefly into the scene. It will have this name.

Enjoy!

unity-rts-camera's People

Contributors

evanhahn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.