Week 11 - Working on project [Progress]

Another week, more tasks to come. As our first week of the project was successful, we split even more tasks to do. This weeks tasks for each of the group member was:

Dalius:

Tasks: Create buttons for Increase/Decrease Fire Rate of the machine, Starting the machine and Create a challenge button.

Description: To how create buttons, I decided to go to YouTube, and see how people are making buttons in VR. I have followed this YouTube video to make a buttons with the press functionality. Link to buttons

After buttons were successfully made, it was time to start working on the functionality of the buttons.

Increase/Decrease fireRate buttons
Button was pressed method

Turret Machine script FireRate

First of all, the entire method of when button is pressed was taken from the tutorial, and I thought, we can make some functions to increase and decrease fireRate in the TurretMachine script.
What this does is every time user presses the increase fireRate button, it adds 0.25 to the fire rate, and turret starts shooting slower. Just so do not make things really messy, or let user spam the buttons and break the game, I decided to put a limit of 2.0 of the fireRate, so it means that turrets will shoot one plate per 2.0 seconds. And the same way goes to the decrease Fire Rate. Decrease fire rate also got a limit, of 0.25, so that things couldn't get messy.

Starting the machine

Machine and button functions


To start the turret/machine to shoot, we had to add some kind of variable, which was bool type of an variable. 

bIsShooting - Indicates that the machine has been started (true/false)
bShotHasFired - this variable was made so that start machine button would not work when it is getting spammed, or pressed a lot of times for no reason, and this indicates, when the shot was shot. 
Everytime before the shot has been made, bShotHasFired is being set to false, so that we could indicate that the shot has not been finished, and we have to wait till the startShooting Method ends. At the end of it , bShotHasFired is being set to true, to indicate that shot was shot from the machine, and that update method can start the timer for another shot.
Challenge button
This task, was a tough one, I had to imagine what could user could do to break the game.



When the challenge button was triggered, challenge begin method starts to run. In the first place, it checks if the machine is still shooting objects, if it is, then it stops and prepares itself for the challenge.
Also, if there are no objects on the platform, its gonna show to user that you need to place an item on the platform to start the challenge. For the challenge, to make things a bit more interesting, Challenge started at fireRate of 2.0, and within 10 secs of the challenge it increases the speed of the turret.
Also, I forgot to mention that startChallengeAttributes method, sets some important things before the challenge starts, such as: Resetting the counter of plates shot, and plates that were hit. Also, to indicate that challenge has been started, bChallengeStarted was changed to true, and we enabled the timer, disabled the texts of the machine speed, and also disabled the Increase/Decrease fireRate buttons .

After the challenge has been done, we are setting the counter of plates shot, and plates that were hit. And some more attributes which are clear enough to understand what it does.

Forgot to mention that, we also made some kind of a dialog, that when the user presses the button,  Start challenge text changes: 
And as we can see in the code, we are using the timer, to change the text every second. After 2 seconds text is being changed to Challenge will start in 5 and it decreases to 0 , and at 0, it changes to GO! and machine starts firing.

Sayed:

We had some hiccups during the project.

Dalius working on the buttons. I was working on the gun and the shooting.

The problem we encountered was that when walk to the buttons and try to press it, the hand would go right through the button and not being able to press it.

I thought it was easy, just add a collision and it work, but it didn’t. I added a grab intractable component, this way when you grab it, it would press the button, but the button would fall off under the table.

We tried everything nothing worked until I saw a tutorial on physics-Based Hands.

For the hand to be able to interact with buttons and not go through objects. An empty object must be created, both hands prefabs will be added to it. and you must manually create capsule objects for each hand.


These prefabs would follow the original prefabs in our controllers. this way the rigid body will detect collisions.

For the shooting guns, I had to find a free sample of a gun and write a script. Fortunately, I found one with script. I just added that, and everything worked as it should. The problem was grabbing any objects with our current hand models. Once we grabbed the gun, the gun and hand would collide, and the hand would get in a weird position, and we knew it is because of the fingers rigid body that prevent it from getting to the right position. Sometimes we grabbed something, we would fly away.

I had this idea, what if grab the guns and the hand models disappear. That way there would be no collision.

This let me learn more about the Interactor events. You must create events when select or exit.

it means that once I grab an object SetActive will be triggered, and the prefabs of the hand will disappear. And when I let go the Boolean changes and the prefabs appear again.



Comments

Popular posts from this blog

Week 2 - Marker based AR

Week 6 - Progress of VR Project

Week 3 - Markerless AR