Lift Demo
|
||
Requirement ID
|
Description
|
Status
|
1.1
|
The system shall recognize when a hand
is added
|
Complete
|
1.1.1
|
If the system recognizes if a hand is
added, the system shall set the hand mesh to visible
|
Complete
|
1.1.2
|
The system shall recognize when the
hand is removed and set the hand mesh to not visible
|
Complete
|
2.1
|
The system shall be able to determine
when a hand has collided with a handler
|
Complete
|
2.1.2
|
If a hand collides with the right
handler, the system shall move the ball right with some torque
|
Complete
|
2.1.3
|
If a hand collides with the Left
handler, the system shall move the ball left with some torque
|
Complete
|
2.1.4
|
If a hand collides with the back
handler, the system shall move the ball backwards with some torque
|
Complete
|
2.1.5
|
If a hand collides with the forward
handler, the system shall move the ball forward with some torque
|
Complete
|
2.1.6
|
If a hand collides with the top
handler, the system shall have the ball jump based on an impulse
|
Complete
|
3.1
|
The system shall be able to change the
balls material if both hands collide with one another
|
Incomplete
|
3.1.2
|
If two hands collide with each other,
the system shall be able to change the balls collision status
|
Incomplete
|
4.1
|
The system shall be able to grab
different objects in a scene using two hands
|
Incomplete
|
As you can see above, I still have quite a few major aspects to still implement in the demo but other than that, I was able to get one portion working fine! So to begin the process I started off with a new project using the rolling ball template in Blueprint. Looking at some of the functionality I changed some methods, added a few functions as well as integrated the Leap Motion Controller onto the pawn blueprint. But that's not really saying much or diving in is it?
To dive into it, in the pawn blueprint of the ball I added the component Leap Motion Controller
When I first did this, I ran into a problem. Upon starting the game, the hands would appear assuming you had your Leap Motion Controller set up. But considering the pawn is a ball that roll's, the hands would roll too. In order to prevent this from occurring I actually just attached the controller as a child of Spring Arm. Thus, the hands would not rotate. So the hands were integrated in the pawn's blueprint, but what is it doing? Nothing really. My goal was to have the hands control the movement of the ball. The way I went about doing this was creating Handlers. Each handler would determine which way the ball would maneuver when a hand collided with it. Thanks to UE4 this was simple in the Pawn's blueprint. I created five box collisions. The names I gave to these handlers were RightHandler, LeftHandler, TopHandler, Forward, Backward. All child's of Spring Arm so there relative rotation are not relative to the ball.
After creating these new components, I placed them in the desire location close to the Leap Motion Controller. Now begins the logic! To begin with the logic I created three functions called MoveRightLeft, MoveForwardBackward, and Jump. These functions say what they need to do. Move the ball right, left, forward, backward or jump. Clicking the + sign at the top right of functions I created my MoveRightLeft function. In it was really only three statements. Setting a boolean called HandCollides to true and if HandCollides is true add a torque to the target ball. In the torque pin, I broke out the vector where I multiplied a float called RollTorque of 50000000.0 value to the parameter XAxis and plugged the value of that to the X coordinate of the vector. To end the function, I created an Input parameter called XAxis of float type.
Thus ending the MoveRightLeft function. The MoveForwardBackward function was very similar. The only difference was, I use the resultant value and plugged it in the Y coordinate and changed the input paramter name to Y Axis.
Lastly, I just needed one more function left. The Jump function. This one was already given, I just made it into a function for organization.
Having the functions finished, I jumped back to the Event graph to get the implementation running in the game loop. Actually implementing was fairly easy, all I had to do was on each begin overlap of a handler, call the desire function relative to the name. On end overlap set HandCollides to false which disables the ball from continuing moving.
Thus completing most part of the Demo. All I needed left was the material changing dynamically on the mesh as well as the ability to grab objects with the Leap Motion Controller. As far as it came down to dynamically changing the mesh, I was very familiar how to do it upon a key press... But not sure how to go about doing it if both hands collided with one another. To actually get the balls material to change dynamically and with it's collision I created an input event called I. My logic behind this was if the ball was not invisible, set the material to visible and set the collision response to ignore all on all objects that are dynamic. If the ball is invisible, change the material back to the original and set the collision response to block world dynamic.
After doing this I decided to just jump into the level to see how the integration worked out and man it's so cool! My goal before actually calling this demo completed is to not only complete my requirements list, but to create the balls movement more smoother through creating a Gyro Ball. Based on the hands location in the gyro ball I want the ball's location to increase whether the hand is moving forward in the ball, forward left ect. Personally I feel this route is much cleaner. My other goal is to actually spend some time designing the level. The current level was just something I threw in to see how the functionality of the pawn works. Can't wait to release version 2 of it!!
No comments:
Post a Comment