一、游戏说明
通过Kinect控制小玩偶来玩Unreal游戏,左右手抬起可左右移动;右手举过头顶,可跳起;还可以发射蜗牛子弹来攻击小鱼。使用UE4的2D效果来实现。
先睹为快,萌萌哒的小小主角:
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a75f976be5.com/resource/attachment/42837b70a8c8c1fd502c9e81cae9894e)
二、主要的实现接口
头文件:
- UFUNCTION(BlueprintCallable, Category = KINECTUE)
- void HandState(const int32 HandType);
-
- UFUNCTION(BlueprintCallable, Category = KINECTUE)
- void StartCheckHandsPushDriveHand();
-
- UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Right Hand Push"))
- virtual void RightHandPush();
-
- UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Left Hand Push"))
- virtual void LeftHandPush();
-
- UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Left Hand Move"))
- virtual void LeftHandMoveLeft();
-
- UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Right Hand Move"))
- virtual void RightHandMoveRight();
-
-
- void RightHandOverHeadForJump();
实现文件,cpp文件:
- void ATwoDPaperCharacter::HandState(const int32 HandType)
- {
- int iFlag = UDKinectHandsReachOutGesture(0, HandType);
- if (GEngine && iFlag == 1)
- {
- const float fMoveSpeed = 1.0f;
- switch (HandType)
- {
- case 1:
- LeftHandMoveLeft();
- break;
- case 2:
- RightHandMoveRight();
- break;
- default:
- break;
- }
- }
- }
-
- void ATwoDPaperCharacter::StartCheckHandsPushDriveHand()
- {
- int iRightFlag = UDKinectRightHandPushGesture(USER_INDEX);
- if (iRightFlag == 1)
- {
- RightHandPush();
- }
-
- int iLeftFlag = UDKinectLeftHandPushGesture(USER_INDEX);
- if (iLeftFlag == 1)
- {
- LeftHandPush();
- }
- }
-
- void ATwoDPaperCharacter::RightHandOverHeadForJump()
- {
- int iRightHandOverHeadFlag = UDKinectRightHandOverHeadGesture(0);
- if (GEngine && iRightHandOverHeadFlag == 1)
- {
- FString TmpString = "Right Hand Over Head now...";
-
- Jump();
- }
- }
三、Blueprint 实现截图(部分)
其中逻辑控制,只展示部分。因为太多了,各个函数也复杂。
下图为受到攻击的Blueprint。
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a75fa646de.com/resource/attachment/b6650a1f9284f48df452ffbf2a1b7ef3)
下面为控制的BP。
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a75fc9a360.com/resource/attachment/20a7a41e00d4f22968ab89ef98d0bac9)
发射蜗牛导弹的射击Blueprint。
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a75fd7d920.com/resource/attachment/e5c51b2e41fee0283405c0c852178509)
四、游戏截图
主要包括,左右移动,跳起,左边发射攻击,右边发射子弹攻击,被小鱼咬到的受伤级别。
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a75ff22bca.com/resource/attachment/8d7b77c648700acd86a4d66ce277436e)
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a76001ae95.com/resource/attachment/068d6105ad3fae8aee300bddfe977fed)
从上面两张图,可看到小潜水员受到小鱼的攻击而变化了颜色。
其中,根据受伤程度不同,共有6种颜色变换。
![Kinect小玩偶游戏-小小潜水员](http://gadimg-10045137.image.myqcloud.com/20171114/5a0a760179d09.com/resource/attachment/092a2f6ffad321adbf2d8261fedd8550)
小小潜水员在向左右发射蜗牛导弹,来攻击小鱼。
五、游戏视频
视频已经上传到Youku.
地址如下:http://v.youku.com/v_show/id_XOTI4NjUyMzIw.html