Kinect小玩偶游戏-小小潜水员

发表于2017-11-14
评论0 1.3k浏览
一、游戏说明

通过Kinect控制小玩偶来玩Unreal游戏,左右手抬起可左右移动;右手举过头顶,可跳起;还可以发射蜗牛子弹来攻击小鱼。使用UE42D效果来实现。

先睹为快,萌萌哒的小小主角:


二、主要的实现接口

头文件:

  1. UFUNCTION(BlueprintCallable, Category = KINECTUE)  
  2. void  HandState(const int32 HandType);  
  3.   
  4. UFUNCTION(BlueprintCallable, Category = KINECTUE)  
  5. void StartCheckHandsPushDriveHand();  
  6.   
  7. UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Right Hand Push"))  
  8. virtual void RightHandPush();  
  9.   
  10. UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Left Hand Push"))  
  11. virtual void LeftHandPush();  
  12.   
  13. UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Left Hand Move"))  
  14. virtual void LeftHandMoveLeft();  
  15.   
  16. UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Right Hand Move"))  
  17. virtual void RightHandMoveRight();  
  18.   
  19.   
  20. void   RightHandOverHeadForJump();  

实现文件,cpp文件:

  1. void ATwoDPaperCharacter::HandState(const int32 HandType)  
  2. {  
  3.     int iFlag = UDKinectHandsReachOutGesture(0, HandType);  
  4.     if (GEngine && iFlag == 1)  
  5.     {  
  6.         const float fMoveSpeed = 1.0f;  
  7.         switch (HandType)  
  8.         {  
  9.         case 1:  
  10.             LeftHandMoveLeft();  
  11.             break;  
  12.         case 2:  
  13.             RightHandMoveRight();  
  14.             break;  
  15.         default:  
  16.             break;  
  17.         }  
  18.     }  
  19. }  
  20.   
  21. void ATwoDPaperCharacter::StartCheckHandsPushDriveHand()  
  22. {  
  23.     int iRightFlag = UDKinectRightHandPushGesture(USER_INDEX);  
  24.     if (iRightFlag == 1)  
  25.     {  
  26.         RightHandPush();  
  27.     }  
  28.   
  29.     int iLeftFlag = UDKinectLeftHandPushGesture(USER_INDEX);  
  30.     if (iLeftFlag == 1)  
  31.     {  
  32.         LeftHandPush();  
  33.     }  
  34. }  
  35.   
  36. void ATwoDPaperCharacter::RightHandOverHeadForJump()  
  37. {  
  38.     int iRightHandOverHeadFlag = UDKinectRightHandOverHeadGesture(0);  
  39.     if (GEngine && iRightHandOverHeadFlag == 1)  
  40.     {  
  41.         FString TmpString = "Right Hand Over Head now...";  
  42.         //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TmpString);  
  43.         Jump();  
  44.     }  
  45. }  

三、Blueprint 实现截图(部分)

其中逻辑控制,只展示部分。因为太多了,各个函数也复杂。

下图为受到攻击的Blueprint。

下面为控制的BP。

发射蜗牛导弹的射击Blueprint。


四、游戏截图 

主要包括,左右移动,跳起,左边发射攻击,右边发射子弹攻击,被小鱼咬到的受伤级别。



上面两张图,可看到小潜水员受到小鱼的攻击而变化了颜色。

其中,根据受伤程度不同,共有6种颜色变换。


小小潜水员在向左右发射蜗牛导弹,来攻击小鱼。


五、游戏视频

      视频已经上传到Youku.

     地址如下:http://v.youku.com/v_show/id_XOTI4NjUyMzIw.html

如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引