Hello,
For a Project of mine, i need a Mobile Input System, that activates an Event, when an Actor is touched (MOBILE Input).
I found this on the UDN: http://udn.epicgames.com/Three/Mobil...Touch%20Events and it'S exactly what i need.
When i use that Code though i get two Errors.
One: Error, 'HandleInputTouch' mismatch delegate 'OnTouch'
and
Two: Error, Bad or missing expression in Call 'OnTouch', parameter 1
I searched the Forum fisrt befor posting and found this Thread: http://forums.epicgames.com/threads/...ndleInputTouch
But i did not really understand who they solved the problem.
My CODE:
MobilePawn
PlayerController:
and Itouchable.uc
Can someone help?
Thanks alot!
For a Project of mine, i need a Mobile Input System, that activates an Event, when an Actor is touched (MOBILE Input).
I found this on the UDN: http://udn.epicgames.com/Three/Mobil...Touch%20Events and it'S exactly what i need.
When i use that Code though i get two Errors.
One: Error, 'HandleInputTouch' mismatch delegate 'OnTouch'
and
Two: Error, Bad or missing expression in Call 'OnTouch', parameter 1
I searched the Forum fisrt befor posting and found this Thread: http://forums.epicgames.com/threads/...ndleInputTouch
But i did not really understand who they solved the problem.
My CODE:
MobilePawn
Code:
class AthypoMobilePawn extends MobilePlaceablePawn implements(ITouchable); function OnTouch(ETouchType Type, float X, float Y) { WorldInfo.Game.Broadcast(self, "Touched:"@self); }
Code:
class AthypoPlayerController extends GamePlayerController; /** Holds the dimensions of the device's screen */ var vector2D ViewportSize; /** If TRUE, a new touch was detected (must be the only touch active) */ var bool bPendingTouch; /** Holds the handle of the most recent touch */ var int PendingTouchHandle; /** Holds the Actor that was selected */ var Actor SelectedActor; /** Maximum distance an Actor can be to be picked */ var float PickDistance; /** Maximum amount the mouse can move between touch and untouch to be considered a 'click' */ var float ClickTolerance; /** Cache a reference to the MobilePlayerInput */ var MobilePlayerInput MPI; /** find actor under touch location * * @PickLocation - Screen coordinates of touch */ function Actor PickActor(Vector2D PickLocation) { local Vector TouchOrigin, TouchDir; local Vector HitLocation, HitNormal; local Actor PickedActor; //Transform absolute screen coordinates to relative coordinates PickLocation.X = PickLocation.X / ViewportSize.X; PickLocation.Y = PickLocation.Y / ViewportSize.Y; //Transform to world coordinates to get pick ray LocalPlayer(Player).Deproject(PickLocation, TouchOrigin, TouchDir); //Perform trace to find touched actor PickedActor = Trace(HitLocation, HitNormal, TouchOrigin + (TouchDir * PickDistance), TouchOrigin, true); //Casting to ITouchable determines if the touched actor can indeed be touched if(Itouchable(PickedActor) != none) { //Call the OnTouch() function on the touched actor Itouchable(PickedActor).OnTouch(ZoneEvent_Touch, PickLocation.X, PickLocation.Y); } //Return the touched actor for good measure return PickedActor; } function HandleInputTouch(int Handle, ETouchType Type, Vector2D TouchLocation, float DeviceTimestamp) { local Actor PickedActor; local int i; //New touch event if(Type == Touch_Began) { //Specify a new touch has occurred PendingTouchHandle = Handle; bPendingTouch = true; } //Touch in progress else if(Type == Touch_Moved) { for(i=0; i<MPI.NumTouchDataEntries; i++) { //Test distance touch has moved and cancel touch if moved too far; update touch location if not if(MPI.Touches[i].Handle == PendingTouchHandle && MPI.Touches[i].TotalMoveDistance > ClickTolerance) { bPendingTouch = false; } } } //End of touch else if(Type == Touch_Ended) { //Check if a touch is active if(Handle == PendingTouchHandle && bPendingTouch) { //Get actor under touch PickedActor = PickActor(TouchLocation); //Check if actor is touchable and set it as selected; clear current selected if not if(ITouchable(PickedActor) != none) { SelectedActor = PickedActor; } else { SelectedActor = none; } //cancel active touch bPendingTouch = false; } WorldInfo.Game.Broadcast(self, "SelectedActor:"@SelectedActor); } } event InitInputSystem() { Super.InitInputSystem(); //Get a reference to the local MobilePlayerInput MPI = MobilePlayerInput(PlayerInput); //Accessing the input handler function to the delegate MPI.OnInputTouch = HandleInputTouch; //get the screen dimensions (used to transform to relative screen coords for the DeProject) LocalPlayer(Player).ViewportClient.GetViewportSize(ViewportSize); } defaultproperties { PickDistance=10000 ClickTolerance=5 InputClass=class'GameFramework.MobilePlayerInput' }
Code:
Interface ITouchable; function OnTouch(ETouchType Type, float X, float Y);
Thanks alot!
Comment