Skip to main content

Game-state Management and Aframe Systems



Most of this past week involved implementing the data management systems that control the current state of the game for the Builder and the Finder.  The basic skeleton of the systems, as well as the components they used, were implemented at the beginning of the week leading up to the Beta milestone (~10 hours), and the rest of the week was spent expanding and polishing these systems (~3-4 hours).  The two systems I focuses on were the Builder system, which which manages the game state of the Builder player, and the Finder system, which does the same for the Finder player.

The Builder system keeps track of which piece of furniture is being built, what step the Builder is on in the build process, as well as how many steps there are to complete the furniture.  Every time a piece is successfully snapped an event is emitted by the scene element and the Builder system picks this up, increments the current step, checks if the furniture is complete, and emits a Socket.io event that informs the Finder what the next piece is or that the furniture is complete.  This system also listens for a Socket.io 'shipping' event from the Finder and uses the data passed to create the new piece in the Builder's environment. 

A table leg appearing in the living room after being shipped by the Finder.  The builder clicks on the box, and the table leg appears.

The Finder system works in conjunction with a 'shipping' component attached to the shipping platform seen in the picture below.  When a furniture piece collides with the shipping platform the shipping component checks with the Finder system whether it is the correct piece; if it is the Finder component then emits a Socket,io event containing the piece id.  The Builder system listens for this event and creates the piece from the id, as stated above.  

The placeholder shipping platform and a table leg in the warehouse.  The Finder drops the table leg on the platform and if it is the correct piece it gets 'shipped'.

The code below demonstrates the process shipping component uses to determine whether the collided piece needs to be shipped or not.

el.addEventListener('hitstart', function (event)
{
    for (var i = 0; i < event.detail.intersectedEls.length; i++)
    {
        let targetEl = event.detail.intersectedEls[i];

        if (targetEl.classList.contains(system.data.requiredPiece))
        {
            // If the dropped piece is the one we are looking for, remove this instance
            // and emit the sendPiece event for the Builder.
            el.sceneEl.removeChild(targetEl);
            socket.emit('sendPiece', { pieceId: system.data.requiredPiece, });
        }
        else
        {
            // If not, launch the piece back at the player.
            targetEl.body.velocity.set(-5, 6, 0);
        }
    }
});

At the moment the values for the number of steps and the pieces required for each step are still hard coded, one job for this next week is to implement a process that allows the systems to pull this information from a database depending on the furniture selected, and I will be working with Priscilla to complete this.  I would also like get game controller supported.

Comments

Popular posts from this blog

Sprint 2 - 3D Modelling the Environments

This week's focus has mainly been on writing the design document and preparing for the alpha prototype (~2hrs). A great majority of the written sections in our proposal is complete while a large chunk of graphics remains to be developed in the coming week. The sooner the design document is complete, the better of an idea we have in how the project will turn out in the end.  On my end, I am responsible for 3D modelling the environments that will be used in the alpha demo. These are also necessary for producing design comps. The environments will be very low poly environments using primitive shapes and basic forms to form the rooms, nothing too extravagant. Below are a few screenshots of the environments in their current state: Living Room (~3hrs) that will be played in VR and the Warehouse (~4hrs) on desktop; all modelled in Maya. Warehouse Back Side Warehouse Front Gate Warehouse Top-Down View Living Room Back View Living Room Front View Living Roo...

Storyboard and Physical Layout

I finished up on some graphical elements for the user interaction specification component of the proposal due this coming Friday. This includes the storyboard panels and the physical layout diagram. As I was researching Oculus Rift physical setups, I had to determine how many sensors we would need for our game. I believe that 2 sensors will be sufficient, since we do not need a true 360 degrees experience as the Builder player will primarily be focused on the 180 degree space in front of them (i.e. the fireplace, the TV, and building the furniture). Our game is not an action packed game with any running or shooting. Of course, the player will still be able to fully look around but they shouldn't have a great need to move in the other 180 degrees of space. This would also take into consideration accessibility to our game, because it costs extra to buy a third sensor (the Rift only comes with 2) as well as requiring adapters and wire extensions. I spent about 4 hours researching ...

Sprint 3 - Design Comps

This week, a large majority of both environments have been modelled (~2hrs)  to their fundamentals. The main focus for me was producing the design comps, which I did by setting up a camera in one angle of the environment that captures a scene from the wireframe. All objects in that shot are UV mapped (~4hrs) then brought to Substance Painter for texturing and rendering (~7hrs). The final results are seen below. The warehouse will contain a wide space for the user to work with. The green platform as seen on the right-hand side of the design comp is a dropbox for them to deliver the correct components, which are found in the scaffolded aisles. These aisles are labelled by the icon by its front, which determines what parts for which piece of furniture is found. The living room has a more simple design that will probably be tweaked and improved over time. Boxes containing the building components sent from the warehouse and are delivered through the chimney. Both of these desi...