Giter Site home page Giter Site logo

godot-splitscreen's Introduction

godot-splitscreen

This addon provides the boilerplate for a standard 1-4 player splitscreen viewport setup. It can add/remove players on-the-fly and responds to changes in window size.

Supports Godot 3.2

Usage

First, instance res://addons/organicpencil.splitscreen/splitscreen.tscn somewhere in the tree.
Set desired border_width and vertical.

And then...

# Add a player. Possible values 0 - 3. Returns a TextureRect with some extra goodies attached
var render = $Splitscreen.add_player(0)

# Assign a camera to the viewport
var cam = Camera.new() # Probably want to store a ref to this camera so you can move it later
render.viewport.add_child(cam)

# Add your HUD
var hud = preload("res://path/to/my_hud.tscn").instance()
render.add_child(hud)

# Player 2
render = $Splitscreen.add_player(1)
...

Cleaning up when a player leaves:

$Splitscreen.remove_player(0)

The viewport can be moved to a different parent if you need to change worlds

var viewport = $Splitscreen.get_player(0).viewport
viewport.get_parent().remove_child(viewport)
my_other_world.add_child(viewport)

Random notes:

  • The borders aren't actually drawn, so you can just throw whatever behind it to change the color.
  • You may want to change the settings in addons/organicpencil.splitscreen/player_viewport.tscn, depending on your project.

godot-splitscreen's People

Contributors

organicpencil 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.