I have the following code (from the UDN Mouse Interface tutorial):
MouseInterfacePlayerController.uc
- class MouseInterfacePlayerController extends PlayerController;
-
- // Null this function
- function UpdateRotation(float DeltaTime);
-
- {
- local MouseInterfacePlayerInput MouseInterfacePlayerInput;
- local IntPoint MousePosition;
-
- // Cast to get the MouseInterfacePlayerInput
- MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerInput);
-
- if (MouseInterfacePlayerInput != None)
- {
- // To retrieve/use the mouse X position
- MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
- // To retrieve/use the mouse Y position
- MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
- }
-
- // Mouse event enum
- enum EMouseEvent
- {
- LeftMouseButton,
- RightMouseButton,
- MiddleMouseButton,
- ScrollWheelUp,
- ScrollWheelDown,
- };
-
- // Handle mouse inputs
- function HandleMouseInput(EMouseEvent MouseEvent, EInputEvent InputEvent)
- {
- local MouseInterfaceHUD MouseInterfaceHUD;
-
- // Type cast to get our HUD
- MouseInterfaceHUD = MouseInterfaceHUD(myHUD);
-
- if (MouseInterfaceHUD != None)
- {
- // Detect what kind of input this is
- if (InputEvent == IE_Pressed)
- {
- // Handle pressed event
- switch (MouseEvent)
- {
- case LeftMouseButton:
- MouseInterfaceHUD.PendingLeftPressed = true;
- break;
-
- case RightMouseButton:
- MouseInterfaceHUD.PendingRightPressed = true;
- break;
-
- case MiddleMouseButton:
- MouseInterfaceHUD.PendingMiddlePressed = true;
- break;
-
- case ScrollWheelUp:
- MouseInterfaceHUD.PendingScrollUp = true;
- break;
-
- case ScrollWheelDown:
- MouseInterfaceHUD.PendingScrollDown = true;
- break;
-
- default:
- break;
- }
- }
- else if (InputEvent == IE_Released)
- {
- // Handle released event
- switch (MouseEvent)
- {
- case LeftMouseButton:
- MouseInterfaceHUD.PendingLeftReleased = true;
- break;
-
- case RightMouseButton:
- MouseInterfaceHUD.PendingRightReleased = true;
- break;
-
- case MiddleMouseButton:
- MouseInterfaceHUD.PendingMiddleReleased = true;
- break;
-
- default:
- break;
- }
- }
- }
- }
-
- // Hook used for the left and right mouse button when pressed
- exec function StartFire(optional byte FireModeNum)
- {
- HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Pressed);
- Super.StartFire(FireModeNum);
- }
-
- // Hook used for the left and right mouse button when released
- exec function StopFire(optional byte FireModeNum)
- {
- HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Released);
- Super.StopFire(FireModeNum);
- }
-
- // Called when the middle mouse button is pressed
- exec function MiddleMousePressed()
- {
- HandleMouseInput(MiddleMouseButton, IE_Pressed);
- }
-
- // Called when the middle mouse button is released
- exec function MiddleMouseReleased()
- {
- HandleMouseInput(MiddleMouseButton, IE_Released);
- }
-
- // Called when the middle mouse wheel is scrolled up
- exec function MiddleMouseScrollUp()
- {
- HandleMouseInput(ScrollWheelUp, IE_Pressed);
- }
-
- // Called when the middle mouse wheel is scrolled down
- exec function MiddleMouseScrollDown()
- {
- HandleMouseInput(ScrollWheelDown, IE_Pressed);
- }
-
- // Null this function
- function UpdateRotation(float DeltaTime);
-
- // Override this state because StartFire isn't called globally when in this function
- auto state PlayerWaiting
- {
- exec function StartFire(optional byte FireModeNum)
- {
- Global.StartFire(FireModeNum);
- }
- }
-
- defaultproperties
- {
- // Set the input class to the mouse interface player input
- InputClass=class'MouseInterfacePlayerInput';
-
-
- }
MouseInterfaceHUD.uc
- class MouseInterfaceHUD extends HUD;
-
- // The texture which represents the cursor on the screen
- var const Texture2D CursorTexture;
- // The color of the cursor
- var const Color CursorColor;
- // Pending left mouse button pressed event
- var bool PendingLeftPressed;
- // Pending left mouse button released event
- var bool PendingLeftReleased;
- // Pending right mouse button pressed event
- var bool PendingRightPressed;
- // Pending right mouse button released event
- var bool PendingRightReleased;
- // Pending middle mouse button pressed event
- var bool PendingMiddlePressed;
- // Pending middle mouse button released event
- var bool PendingMiddleReleased;
- // Pending mouse wheel scroll up event
- var bool PendingScrollUp;
- // Pending mouse wheel scroll down event
- var bool PendingScrollDown;
- // Cached mouse world origin
- var Vector CachedMouseWorldOrigin;
- // Cached mouse world direction
- var Vector CachedMouseWorldDirection;
- // Last mouse interaction interface
- var MouseInterfaceInteractionInterface LastMouseInteractionInterface;
-
-
- function MouseInterfaceInteractionInterface; GetMouseActor(optional out Vector HitLocation, optional out Vector HitNormal);
- {
- local MouseInterfaceInteractionInterface MouseInteractionInterface;
- local MouseInterfacePlayerInput MouseInterfacePlayerInput;
- local Vector2D MousePosition;
- local Actor HitActor;
-
- // Ensure that we have a valid canvas and player owner
- if (Canvas == None || PlayerOwner == None)
- {
- return None;
- }
-
- // Type cast to get the new player input
- MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
-
- // Ensure that the player input is valid
- if (MouseInterfacePlayerInput == None)
- {
- return None;
- }
-
- // We stored the mouse position as an IntPoint, but it's needed as a Vector2D
- MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
- MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
- // Deproject the mouse position and store it in the cached vectors
- Canvas.DeProject(MousePosition, CachedMouseWorldOrigin, CachedMouseWorldDirection);
-
- // Perform a trace actor interator. An interator is used so that we get the top most mouse interaction
- // interface. This covers cases when other traceable objects (such as static meshes) are above mouse
- // interaction interfaces.
- ForEach TraceActors(class'Actor', HitActor, HitLocation, HitNormal, CachedMouseWorldOrigin + CachedMouseWorldDirection * 65536.f, CachedMouseWorldOrigin,,, TRACEFLAG_Bullet)
- {
- // Type cast to see if the HitActor implements that mouse interaction interface
- MouseInteractionInterface = MouseInterfaceInteractionInterface(HitActor);
- if (MouseInteractionInterface != None)
- {
- return MouseInteractionInterface;
- }
- }
-
- return None;
- }
-
- function Vector GetMouseWorldLocation()
- {
- local MouseInterfacePlayerInput MouseInterfacePlayerInput;
- local Vector2D MousePosition;
- local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
-
- // Ensure that we have a valid canvas and player owner
- if (Canvas == None || PlayerOwner == None)
- {
- return Vect(0, 0, 0);
- }
-
- // Type cast to get the new player input
- MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
-
- // Ensure that the player input is valid
- if (MouseInterfacePlayerInput == None)
- {
- return Vect(0, 0, 0);
- }
-
- // We stored the mouse position as an IntPoint, but it's needed as a Vector2D
- MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
- MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
- // Deproject the mouse position and store it in the cached vectors
- Canvas.DeProject(MousePosition, MouseWorldOrigin, MouseWorldDirection);
-
- // Perform a trace to get the actual mouse world location.
- Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
- return HitLocation;
- }
-
- local MouseInterfacePlayerInput MouseInterfacePlayerInput;
- local IntPoint MousePosition;
-
- // Ensure that we have a valid PlayerOwner
- if (PlayerOwner != None)
- {
- // Cast to get the MouseInterfacePlayerInput
- MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
-
- if (MouseInterfacePlayerInput != None)
- {
- // To retrieve/use the mouse X position
- MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
- // To retrieve/use the mouse Y position
- MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
- }
- }
-
- function Vector GetMouseWorldLocation()
- {
- local MouseInterfacePlayerInput MouseInterfacePlayerInput;
- local Vector2D MousePosition;
- local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
-
- // Ensure that we have a valid canvas and player owner
- if (Canvas == None || PlayerOwner == None)
- {
- return Vect(0, 0, 0);
- }
-
- // Type cast to get the new player input
- MouseInterfacePlayerInput = MouseInterfacePlayerInput(PlayerOwner.PlayerInput);
-
- // Ensure that the player input is valid
- if (MouseInterfacePlayerInput == None)
- {
- return Vect(0, 0, 0);
- }
-
- // We stored the mouse position as an IntPoint, but it's needed as a Vector2D
- MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
- MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
- // Deproject the mouse position and store it in the cached vectors
- Canvas.DeProject(MousePosition, MouseWorldOrigin, MouseWorldDirection);
-
- // Perform a trace to get the actual mouse world location.
- Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
- return HitLocation;
- }
-
- defaultproperties
- {
- // Set to false if you wish to use Unreal's player input to retrieve the mouse coordinates
- CursorColor=(R=255,G=255,B=255,A=255)
- CursorTexture=Texture2D'EngineResources.Cursors.Arrow'
-
- }
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
// Null this function
function UpdateRotation(float DeltaTime);