A-Frame kit of components for making a simple WebVR shooter minigame.
npm install aframe-super-shooter-kitA-Frame kit of components for making a simple WebVR
shooter minigame. From the creators of A-Frame, Supermedium, and Supercraft.
The kit is set of simple and easy to use components to provide a way of
building simple shooting experiences, where a "shooter" shoots "bullets" that
can hit "targets". A large chunk of the game can be handled at just the
declarative A-Frame layer in HTML.
1. One bullet entity acts as a template for the instances of shot bullets.
2. Entity with shooter component attached (e.g., a gun) spawns bullets onshoot event from its position.
3. Collisions among bullet's and target's bounding boxes are checked.
4. Health and life of targets are calculated (hit and die events).
So we define which entities are bullets, shooters, and targets, and then wire
up the game using controls and progress the game with events.
Video of Supercraft + Super Shooter Kit workflow
The shooter component should be attached to a controller for gun. But it can
also be attached to the camera to support 2D / desktop or normal smartphone if
wired to mouse or touch.
| Property | Description | Default Value |
| -------- | ----------- | ------------- |
| activeBulletType | Name of current active bullet the shooter is firing. | 'normal' |
| bulletTypes | Array of possible bullet names. | ['normal'] |
| cycle | A flag to tell when swapping to the next or prev bullet type, cycle to the first or last type when reaching the last or first type respectively. | false |
#### Events
These events can be triggered with entity.emit(eventName).
| Event Name | Effect |
|----------------|-------------------------------------------------------------|
| shoot | Shoot a bullet. |
| changebullet | Swap bullet type (either prev, next, or name of bullet. |
| Property | Description | Default Value |
|--------------|---------------------------------------------------------------------------|---------------|
| damagePoints | How many health points to remove from target when hitting target. | 1.0 |
| maxTime | Life time of bullet in seconds. When elapsed, the bullet will be removed. | 1.0 |
| name | Name of the bullet type. | normal |
| poolSize | How many copies of this bullet can be on screen at once. | 10 |
| speed | Speed of bullet in meters per second. | 1.0 |
| Property | Description | Default Value |
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| active | Whether this target is included in collision tests. | true |
| healthPoints | Number of hit or health points of the target. When a bullet hits this target, its health points will decrease by the bullet's damage points. When the target reaches 0 health points, then the event 'die' is emitted on the target. | 1 |
| static | Whether this object does not ever move or change shape. If set to false, then the bounding box is recalculated continuously. | true |
#### Members
Component members can be accessed by like entity.components.target.lastBulletHit:
| Member | Description |
|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| lastBulletHit | Reference object to the last bullet object3D that hit the target. Useful for attaining the position of where the bullet contacted the target. |
#### Events
Events emitted on the target that we can listen to, to perhaps show an
explosion effect on target hit or die.
| Event Name | Description |
|------------|--------------------------------------------------------|
| hit | Target was hit by a bullet. |
| die | Target ran out of healthPoints and has been destroyed. |
Supercraft is an A-Frame WebVR
application that lets you build low-poly VR assets inside of VR with your
hands, and export them to Web or JSON! With the shooter kit providing dead-easy
components, A-Frame letting you do things in just HTML, and ability to create
good assets without modeling experience, WebVR development is made simple.
The advantage of the Supercraft JSON exports alongside
aframe-supercraft-loader
and aframe-supercraft-thing
is that they are tailored for A-Frame resulting in extremely small file sizes
and performant through geometry merging.
All 3D assets in this scene are delivered within a single 190KB JSON file:
Supercraft Shooter. All
the assets in the game were done using Supercraft in 45 minutes, and the
code is just dozens of lines of Javascript and HTML. Game created in an
afternoon.
An extremely cool workflow is using the supercraft-loader to "live-reload"
assets. The Supercraft JSON is hosted on the Web via name; we just need to dosupercraft-loader="name: my-supercraft-site", and whenever we publish an update
to my-supercraft-site within Supercraft, the scene will automatically have
access to the fresh new assets.
And supercraft-thing-loader can be used to pick individual objects out of a
Supercraft scene of objects. You can create all your assets in one scene, make
sure they have good scale relative to one another, tweak them all at once!
See the Supercraft Shooter example source
code.
Install and use by directly including the browser files:
``html
$3
Install via npm:
`bash
npm install aframe-super-shooter-kit
`Then require and use.
`js
require('aframe');
require('aframe-super-shooter-kit');
``