Code Monkey home page Code Monkey logo

multiplayer-fps's Introduction

Multiplayer-FPS

A multiplayer first person shooter game based on Unity3D, to improve players' game experience, I added different kinds of input device such like Kinect, Xbox controller, Leap motion and VR Glasses. (All in different branches)

Game logic and function

  • Login panel

    • Input your player name and the room name that you want to join
    • Click 'join or create room' button to join the room (or create and then join it)
    • The network connection state shows on the bottom left corner img
  • Game interface

    • Player's HP showing on the top left corner
    • The message panal showing on the bottom left corner, which is used to notify player other players status (like dead or respawn)
    • A gun (AK-47) will always show on the bottom right corner above every thing you can see
    • A red shooting sight always in the center of the screen
  • Player model

    • There are three type of player model:

      • Policeman: a policeman-like model with yellow skin
      • RobotX: a robot-like model with dark pink skin
      • RobotY: a robot-like model with dark blue skin
    • Animation:

      • Walk towards four different direction
      • Run towards four different direction
      • Jump without affact upper part body (achieved by unity3d body mask)
      • Shooting without affact lower part body (achieved by unity3d body mask)
      • All the original models and their animation can be get from Mixamo, which is a pretty good game model website runned by Adobe
    • Unity Blend Tree

      • This is used to make the player walk or run more naturally, it uses interpolation function to map different combinations of user input to the different animations.
      • img
    • State Machine

      • Player state machine with many layers
  • Player movement

    • Walking && Running && Aiming
    • Jumping
    • Dying
  • Gun model

    • The orignal gun model (AK-47) was from Unity Assets Store
    • Added shooting animation by setting keyframes in unity3d animation panel img
  • Networking

    • Used Photon Unity Networking which is a good network model in Unity Assets Store
  • Bullet effects

    • Bullet will have different effects when hit different materials
    • Wood
    • Ground
    • Metal
    • Concrete
    • Water
  • Door animation

    • Door will automatically open when there is someone near it, and close when no one around
    • Before open
    • After open

Script files

  • CameraRotation.cs
    • Used to rotate the scene camera in every updated frame
  • DoorAnimtion.cs
    • Used to control the door animation, detect if player enter or exit the door trigger area
  • GunFirstPersonView.cs
    • Used to control the first person view of gun shooting animation
  • GunShooting.cs
    • Used to control the gun shooting action on the network domain, send shooting function to evert client if necessary
  • IKControl.cs
    • Used to make sure the model hold the gun on their hand no matter how they moved and rotated
  • ImpactLifeCycle.cs
    • Used to destory the bullet after several seconds to save CPU and memory
  • NameTag.cs
    • Used to set other players' name above their head on local game
  • NetworkManager.cs
    • Used to control the whole network connection
  • PlayerHealth.cs
    • Used to calculate and update each player's health
  • PlayerNetworkMover.cs
    • Used to sychronize player's postion among different clients
  • ShowName.cs
    • Used to show the player name above their head
  • WeaponPos.cs
    • Used to move the gun to the place near player's hand

Input Devices

  • Mouse and keyboard

    • The traditional way
    • Cheap and easy to use
  • Kinect

    • Detail see below
    • This part was implemented by my friend Ruochen Jiang, thanks to him!
  • Xbox Controller

    • Like the combination of mouse and keyboard
    • Most Xbox games use this way to play
  • Leap Motion

    • User hand gestrue to control game
    • More advance, maybe future it will be more popular
  • VR glasses

    • More vivid, like reality
    • Recently very popular but devices are most likely expensive
    • Player can't move now due to my device limitation

Kinect Detail

  • Tools and Platform:

    • Kinect for Xbox One
    • Kinect for Windows SDK
    • Unity
    • Visual Studio
  • Recogonition Method:

    • Use Kinect for Windows SKD (BodySourceManager) to get the positions of skeleton of the player, then use those positions to judge the actions of moving, jumping, shooting and view rotation as game’s input.

    • Shooting: Use the action of lifting right arm to shoot in the game, so I calculated the distance between the nodes of skeleton of right hand and right shoulder. If it reaches a critical value, then mark the action as shooting.

    • Moving: Use the action of stepping front, back, left and right to move in the game, so I recognized moving actions by the offset of right foot’s skeleton node on x-z plane. If the offset reaches a critical value, it will be recognized as moving.

    • Jumping: Use the action of jumping to jump in the game. I used offset of right foot’s skeleton node on z-axis to recognize jumping. If the offset reaches a critical value, I recognized the action as jumping.

    • View Rotation: Use right hand as a virtual mouse to control the camera rotation. I record the initial position of left hand as the initial position of mouse. Then recognize the camera rotation by left hand’s offset.

multiplayer-fps's People

Contributors

armour avatar

Watchers

James Cloos avatar Thiago Bocchile 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.