Home Unreal Engine
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

Trying to compile, but getting errors that don't make sense. Please Help! :(

I have the following code (from the UDN Mouse Interface tutorial):

MouseInterfacePlayerController.uc
  1. class MouseInterfacePlayerController extends PlayerController;
  2.  
  3. // Null this function
  4. function UpdateRotation(float DeltaTime);
  5.  
  6. {
  7. local MouseInterfacePlayerInput MouseInterfacePlayerInput;
  8. local IntPoint MousePosition;
  9.  
  10. // Cast to get the MouseInterfacePlayerInput
  11. MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerInput);
  12.  
  13. if (MouseInterfacePlayerInput != None)
  14. {
  15. // To retrieve/use the mouse X position
  16. MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
  17. // To retrieve/use the mouse Y position
  18. MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
  19. }
  20.  
  21. // Mouse event enum
  22. enum EMouseEvent
  23. {
  24. LeftMouseButton,
  25. RightMouseButton,
  26. MiddleMouseButton,
  27. ScrollWheelUp,
  28. ScrollWheelDown,
  29. };
  30.  
  31. // Handle mouse inputs
  32. function HandleMouseInput(EMouseEvent MouseEvent, EInputEvent InputEvent)
  33. {
  34. local MouseInterfaceHUD MouseInterfaceHUD;
  35.  
  36. // Type cast to get our HUD
  37. MouseInterfaceHUD = MouseInterfaceHUD(myHUD);
  38.  
  39. if (MouseInterfaceHUD != None)
  40. {
  41. // Detect what kind of input this is
  42. if (InputEvent == IE_Pressed)
  43. {
  44. // Handle pressed event
  45. switch (MouseEvent)
  46. {
  47. case LeftMouseButton:
  48. MouseInterfaceHUD.PendingLeftPressed = true;
  49. break;
  50.  
  51. case RightMouseButton:
  52. MouseInterfaceHUD.PendingRightPressed = true;
  53. break;
  54.  
  55. case MiddleMouseButton:
  56. MouseInterfaceHUD.PendingMiddlePressed = true;
  57. break;
  58.  
  59. case ScrollWheelUp:
  60. MouseInterfaceHUD.PendingScrollUp = true;
  61. break;
  62.  
  63. case ScrollWheelDown:
  64. MouseInterfaceHUD.PendingScrollDown = true;
  65. break;
  66.  
  67. default:
  68. break;
  69. }
  70. }
  71. else if (InputEvent == IE_Released)
  72. {
  73. // Handle released event
  74. switch (MouseEvent)
  75. {
  76. case LeftMouseButton:
  77. MouseInterfaceHUD.PendingLeftReleased = true;
  78. break;
  79.  
  80. case RightMouseButton:
  81. MouseInterfaceHUD.PendingRightReleased = true;
  82. break;
  83.  
  84. case MiddleMouseButton:
  85. MouseInterfaceHUD.PendingMiddleReleased = true;
  86. break;
  87.  
  88. default:
  89. break;
  90. }
  91. }
  92. }
  93. }
  94.  
  95. // Hook used for the left and right mouse button when pressed
  96. exec function StartFire(optional byte FireModeNum)
  97. {
  98. HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Pressed);
  99. Super.StartFire(FireModeNum);
  100. }
  101.  
  102. // Hook used for the left and right mouse button when released
  103. exec function StopFire(optional byte FireModeNum)
  104. {
  105. HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Released);
  106. Super.StopFire(FireModeNum);
  107. }
  108.  
  109. // Called when the middle mouse button is pressed
  110. exec function MiddleMousePressed()
  111. {
  112. HandleMouseInput(MiddleMouseButton, IE_Pressed);
  113. }
  114.  
  115. // Called when the middle mouse button is released
  116. exec function MiddleMouseReleased()
  117. {
  118. HandleMouseInput(MiddleMouseButton, IE_Released);
  119. }
  120.  
  121. // Called when the middle mouse wheel is scrolled up
  122. exec function MiddleMouseScrollUp()
  123. {
  124. HandleMouseInput(ScrollWheelUp, IE_Pressed);
  125. }
  126.  
  127. // Called when the middle mouse wheel is scrolled down
  128. exec function MiddleMouseScrollDown()
  129. {
  130. HandleMouseInput(ScrollWheelDown, IE_Pressed);
  131. }
  132.  
  133. // Null this function
  134. function UpdateRotation(float DeltaTime);
  135.  
  136. // Override this state because StartFire isn't called globally when in this function
  137. auto state PlayerWaiting
  138. {
  139. exec function StartFire(optional byte FireModeNum)
  140. {
  141. Global.StartFire(FireModeNum);
  142. }
  143. }
  144.  
  145. defaultproperties
  146. {
  147. // Set the input class to the mouse interface player input
  148. InputClass=class'MouseInterfacePlayerInput';
  149.  
  150. }

MouseInterfaceHUD.uc
  1. class MouseInterfaceHUD extends HUD;
  2.  
  3. // The texture which represents the cursor on the screen
  4. var const Texture2D CursorTexture;
  5. // The color of the cursor
  6. var const Color CursorColor;
  7. // Pending left mouse button pressed event
  8. var bool PendingLeftPressed;
  9. // Pending left mouse button released event
  10. var bool PendingLeftReleased;
  11. // Pending right mouse button pressed event
  12. var bool PendingRightPressed;
  13. // Pending right mouse button released event
  14. var bool PendingRightReleased;
  15. // Pending middle mouse button pressed event
  16. var bool PendingMiddlePressed;
  17. // Pending middle mouse button released event
  18. var bool PendingMiddleReleased;
  19. // Pending mouse wheel scroll up event
  20. var bool PendingScrollUp;
  21. // Pending mouse wheel scroll down event
  22. var bool PendingScrollDown;
  23. // Cached mouse world origin
  24. var Vector CachedMouseWorldOrigin;
  25. // Cached mouse world direction
  26. var Vector CachedMouseWorldDirection;
  27. // Last mouse interaction interface
  28. var MouseInterfaceInteractionInterface LastMouseInteractionInterface;
  29.  
  30.  
  31. function MouseInterfaceInteractionInterface; GetMouseActor(optional out Vector HitLocation, optional out Vector HitNormal);
  32. {
  33. local MouseInterfaceInteractionInterface MouseInteractionInterface;
  34. local MouseInterfacePlayerInput MouseInterfacePlayerInput;
  35. local Vector2D MousePosition;
  36. local Actor HitActor;
  37.  
  38. // Ensure that we have a valid canvas and player owner
  39. if (Canvas == None || PlayerOwner == None)
  40. {
  41. return None;
  42. }
  43.  
  44. // Type cast to get the new player input
  45. MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
  46.  
  47. // Ensure that the player input is valid
  48. if (MouseInterfacePlayerInput == None)
  49. {
  50. return None;
  51. }
  52.  
  53. // We stored the mouse position as an IntPoint, but it's needed as a Vector2D
  54. MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
  55. MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
  56. // Deproject the mouse position and store it in the cached vectors
  57. Canvas.DeProject(MousePosition, CachedMouseWorldOrigin, CachedMouseWorldDirection);
  58.  
  59. // Perform a trace actor interator. An interator is used so that we get the top most mouse interaction
  60. // interface. This covers cases when other traceable objects (such as static meshes) are above mouse
  61. // interaction interfaces.
  62. ForEach TraceActors(class'Actor', HitActor, HitLocation, HitNormal, CachedMouseWorldOrigin + CachedMouseWorldDirection * 65536.f, CachedMouseWorldOrigin,,, TRACEFLAG_Bullet)
  63. {
  64. // Type cast to see if the HitActor implements that mouse interaction interface
  65. MouseInteractionInterface = MouseInterfaceInteractionInterface(HitActor);
  66. if (MouseInteractionInterface != None)
  67. {
  68. return MouseInteractionInterface;
  69. }
  70. }
  71.  
  72. return None;
  73. }
  74.  
  75. function Vector GetMouseWorldLocation()
  76. {
  77. local MouseInterfacePlayerInput MouseInterfacePlayerInput;
  78. local Vector2D MousePosition;
  79. local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
  80.  
  81. // Ensure that we have a valid canvas and player owner
  82. if (Canvas == None || PlayerOwner == None)
  83. {
  84. return Vect(0, 0, 0);
  85. }
  86.  
  87. // Type cast to get the new player input
  88. MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
  89.  
  90. // Ensure that the player input is valid
  91. if (MouseInterfacePlayerInput == None)
  92. {
  93. return Vect(0, 0, 0);
  94. }
  95.  
  96. // We stored the mouse position as an IntPoint, but it's needed as a Vector2D
  97. MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
  98. MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
  99. // Deproject the mouse position and store it in the cached vectors
  100. Canvas.DeProject(MousePosition, MouseWorldOrigin, MouseWorldDirection);
  101.  
  102. // Perform a trace to get the actual mouse world location.
  103. Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
  104. return HitLocation;
  105. }
  106.  
  107. local MouseInterfacePlayerInput MouseInterfacePlayerInput;
  108. local IntPoint MousePosition;
  109.  
  110. // Ensure that we have a valid PlayerOwner
  111. if (PlayerOwner != None)
  112. {
  113. // Cast to get the MouseInterfacePlayerInput
  114. MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
  115.  
  116. if (MouseInterfacePlayerInput != None)
  117. {
  118. // To retrieve/use the mouse X position
  119. MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
  120. // To retrieve/use the mouse Y position
  121. MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
  122. }
  123. }
  124.  
  125. function Vector GetMouseWorldLocation()
  126. {
  127. local MouseInterfacePlayerInput MouseInterfacePlayerInput;
  128. local Vector2D MousePosition;
  129. local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
  130.  
  131. // Ensure that we have a valid canvas and player owner
  132. if (Canvas == None || PlayerOwner == None)
  133. {
  134. return Vect(0, 0, 0);
  135. }
  136.  
  137. // Type cast to get the new player input
  138. MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
  139.  
  140. // Ensure that the player input is valid
  141. if (MouseInterfacePlayerInput == None)
  142. {
  143. return Vect(0, 0, 0);
  144. }
  145.  
  146. // We stored the mouse position as an IntPoint, but it's needed as a Vector2D
  147. MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
  148. MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
  149. // Deproject the mouse position and store it in the cached vectors
  150. Canvas.DeProject(MousePosition, MouseWorldOrigin, MouseWorldDirection);
  151.  
  152. // Perform a trace to get the actual mouse world location.
  153. Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
  154. return HitLocation;
  155. }
  156.  
  157. defaultproperties
  158. {
  159. // Set to false if you wish to use Unreal's player input to retrieve the mouse coordinates
  160. CursorColor=(R=255,G=255,B=255,A=255)
  161. CursorTexture=Texture2D'EngineResources.Cursors.Arrow'
  162.  
  163. }

I'm getting all kinds of errors between the two files. I've tried to fix the problems, but they either look right to me or break even further.

Errors:
Error 1 Walker: mismatched tree node: <unexpected: [@849,4072:4072='<EOF>',<-1>,157:1], resync={ local MouseInterfacePlayerInput MouseInterfacePlayerInput; local IntPoint MousePosition; // Cast to get the MouseInterfacePlayerInput MouseInterfacePlayerInput = C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfacePlayerController.uc 10 25
Error 2 Parser: mismatched input '<EOF>' expecting RBRACE C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfacePlayerController.uc 157 1
Error 3 Parser: no viable alternative at input '<EOF>' C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfacePlayerController.uc 157 1
Error 4 Walker: mismatched tree node: <mismatched token: [@242,1473:1473=';',<117>,36:43], resync=;> expecting <UP> C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 36 44
Error 5 Parser: mismatched input ';' expecting LPAREN C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 36 44
Error 6 Parser: missing RPAREN at 'out' C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 36 69
Error 7 Walker: mismatched tree node: <unexpected: [@253,1520:1520=',',<62>,36:90], resync=GetMouseActor(optional out Vector HitLocation,> expecting <UP> C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 36 91 Week3_PT1
Error 8 Parser: no viable alternative at input ',' C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 36 91
Error 9 Parser: no viable alternative at input ')' C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 36 122
Error 10 Parser: missing EndOfFile at 'local' C:\UDK\UDK-2012-10\Development\Src\Girod_Lisa_W3_Src\Classes\MouseInterfaceHUD.uc 112 2

Any help fixing this would be greatly appreciated (I'll love you forever and ever and ever). I've been trying to figure this out for several days and it's frustrated me to the point of no sleep. Thank you for reading my post.

Replies

Sign In or Register to comment.