Skip to content

operskaas/VirtualBall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Ball

Virtual Ball is a virtual reality paintball simulation that supports the HTC Vive.

Installation

The zip file is hosted on itch.io here

After downloading, extract the file and run the executable contained within.

NB: You must have SteamVR installed and running, as well as a connected HTC Vive and a PC with recommended minimum specs.

Playing

Movement

Virtual Ball utilizes what is commonly referred to as 'artificial locomotion'. Touching anywhere on either of the Vive controller's touchpads will cause you to move at a constant velocity in the direction of touch, relative to where you are looking.

The reason for the constant speed is to eliminate linear acceleration of any kind, thereby minimizing nausea. You can change directions while moving, but this is inadvisable because it is another kind of acceleration that may cause nausea.

If you ever feel nauseous, take the HTC Vive headset off and don't enter VR again for at least 30 minutes

Interacting with the paintball gun (marker)

When the game is started, there will be a red paintball gun floating close to you. In order to pick it up, move one of the Vive controllers close to the grip of the paintball gun and squeeze the grip buttons on the controller. This will anchor the paintball gun to your controller.

When you have picked up the paintball gun, you can shoot by simply pulling the trigger. Currently the gun is set to fire on every pull and release of the trigger. Note that the first time you shoot, the game will begin.

Gameplay

Upon shooting your first paintball, the first opposing computer player will spawn down range. If they see you, they will shoot at you, so be ready to dodge, or hide behind a bunker! You will have approximately 1.5 seconds to try to shoot them before they disappear and respawn in a different, random location, again trying to shoot you. The game will be over after 45 seconds, and a display will pop up to let you know how you did. Stats will include:

  • Number of paintballs used
  • Number of targets hit
  • Number of targets spawned
  • Your score (calculated based on your targets hit and paintballs used)
  • The local high score

Code

Virtual Ball is written in C# using Unity3D. The MiniGameController script keeps track of the game stats and spawns the targets.

Firing a Paintball

A BallShooter script is attached to the end of the barrel of each paintball gun, which has a public method ShootBall() that spawns a ball and gives it an initial velocity. This method is called by an event listener listening for trigger pulls, as well as the AISight script described further below.

The velocity will have a random magnitude between 85.7 and 88.3 meters per second, and there will be a small, randomly oriented constant force applied that is meant to mimic ball spin. This is for more realistic paintball flight. In addition, once in flight, the paintballs are subject to air resistance, so they slow down over time. In order to not clog up memory, paintballs will destroy themselves after four seconds, since if they haven't hit anything by then, they probably never will.

Since sometimes a paintball is going so fast that it will be able to avoid a collision from one frame to the next, the paintball also performs a RayCast in the direction it is heading and with the distance it predicts it will travel in the next frame. If the RayCast hits, it will move the paintball to the location of the RayCast hit, and the collision logic will take over from there.

Paintball Splat

When a paintball collides with a collider, the paintball will 'splat' if the relative velocity of the paintball to the collider is high enough, and if the angle of collision is low enough. If these conditions are not met, the paintball will bounce, which does not count as a 'hit'.

If the conditions for a 'hit' are met, the ball will destroy itself and instantiate an image of a splat, randomly rotated, and oriented so its normal lines up with the normal for the surface that it's being overlaid on. If the hit is on a target, this will trigger the target to destroy itself and instantiate an explosion in its place, and tell the MiniGameController to increment the number of targets hit.

Paintball splats will also destroy themselves after ten seconds, in order to clear the memory.

AI

The targets that shoot back at you have a script that allows them to know exactly where the head of the player is. Every frame, it will RayCast exactly toward the head of the player, and if the RayCast hits the player, it knows that the player is in sight. If the player is in sight, and within the specified field-of-view, It will fire in a direction above the player that compensates for paintball drop, but with a one second delay after having spotted the player.

Future Directions

  • Online multiplayer for realistic paintball battles.
    • 3v3
    • Teamspeak using the built-in Vive microphone

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published