Giter Site home page Giter Site logo

tranquilmarmot / altspacevr-project-unity-cursor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from altspacevr/altspacevr-project-unity-cursor

0.0 2.0 0.0 46.96 MB

Completed project for AltspaceVR

ASP 62.84% C# 12.69% JavaScript 23.19% GLSL 1.28%

altspacevr-project-unity-cursor's Introduction

AltspaceVR Programming Project - Unity Cursor

Nate Moore

Part 1 - 3D Cursor

Pretty simple; the cursor's location is represented by a quaternion that gets rotated by the player's mouse. Ray cast gets sent out from the camera in the direction of the quaternion, and if it hits something it places the cursor there. If it doesn't hit anything, it puts the cursor on a sphere around the player.

As for rendering the cursor, rather than writing my own shader I used Unity 5's built-in default shader, and set the "emission" value to be the desired color of the cursor. The cursor is rendered with its own camera that just renders the cursor, so that it is always on top no matter what. The default camera doesn't render the cursor at all.

I added right-click as an extra modifier to allow mouse look (along with the defaulted shift keys), and I modified the escape key's behavior to just unlock the mouse, rather than fulling quitting the game. Unfortunately, this means that to exit you have to do an Alt+F4 (or Command+Q if you roll with Apple). Or run it in windowed mode, unlock the mouse, and close the window normally.

Part 2 - Enhancements

I had fun with this! As you start the scene, you'll notice big red buttons on the ground in front of you with labels floating on top of them (who doesn't like pressing big red buttons?!)

They have a couple functions:

  • Pull: This pulls the selected object towards you
  • Push: This pushes the selected object away from you
  • Grab: Grabs an object so it can be moved around
  • Fling: Allows the player to fling an object around using the cursor
  • Clone: Clones the selected object
  • Explode: Causes an explosion at the selected object, sending it into the air and anything around it flying. Also lets out a neat particle effect, using Unity's default particle system.
  • Disable Gravity: Turn on "space simulator" mode and have objects float around! Doesn't effect the player; the player must have special space boots.
  • Flip Gravity: Turn the world upside down! Makes everything float towards the ceiling

All of the code for the object manipulation is in ForceModule.cs, which is attached to the main camera along with the cursor. The button code is in WorldButton.cs, which is extended by ToggleableWorldButton.cs.

You can only have one "mode" active at a time, so all the buttons (aside from the gravity mainpulators) act as radio buttons and only one can be pressed down at a time (the active mode is displayed in the top-left corner of the screen). The code for the radio list is in ToggleableWorldButtonRadioList.cs, and basically just makes sure only one of its children is pressed at any given time.

I also added a cool glowing transparent bouncing ball to the scene, because I got bored with the lamps.

Fun stuff:

  • Make a bunch of clones. Blow them up.
  • Turn off gravity. Blow stuff up.
  • Reverse gravity, then un-reverse it and turn it off before everything hits the ground. Then blow stuff up.
  • Make a bunch of clones, reverse gravity, un-reverse gravity, turn gravity off, and blow stuff up.

No known issues or bugs. Let me know if you find any!!! The project will probably only work in Unity 5, but the "Builds" folder has an x86 build of it.

##Acknowledgements

Assets used in this project are from Free Furniture Props

altspacevr-project-unity-cursor's People

Contributors

gavanwilhite avatar gfodor avatar tranquilmarmot 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.