- Gyro/Accelerometer looking,
- Touch looking,
TIP: For emulating mobile controls on mobile use UDK Remote Tool. Thanks to it you will be able to tap, move your device and test controls on PC without needed to build the game on device.
To move forward we will need some class that we can get to from any other classes. As far I can know Epic is working on better solution for game states etc but we don't need it right now.
Create new ENUM and name it ControlType, add three values to it:
Create new ENUM and name it ControlType, add three values to it:
- Mobile_Tilt,
- Mobile_Touch,
- PC
Open MyGame and create new variable Controls which should extend from ControlTypeEnum.
Create Begin Play Event and set Controls to Mobile_Tilt. For now here we will change control types.
Open Project Settings -> Input, and clear Default Touch Interface.
Tilt Controls
Open MyCharacter and create variables:
- LastTilt - float,
- TiltSensitivity - float set to: 40,
In UE3 everything connected to input was made in PlayerController but I see that inputs in examples are done in Characters so we will do it in MyCharacter.
Go to Event Graph and add Tilt Event like this:
Use UDKRemote tool to test results. Tilt is finished at this point. I really like to control shooters like that when there is no movement. It's easy and intuitive to control look-at like that.
Touch Controls
In MyGame in BeginPlay event change Controls to Mobile_Touch.
Go to MyController (we will do it here because it's messy) and add variables:
- LastX (float),
- LastY (float),
- WasTouched (bool - set to true),
Add Mouse X event and create this blueprint (thanks Andrzej!):
I'm using MouseX because Tick isn't working with Adding Inputs. It's similar to Tilt Controls but here we are making sure that we aren't making changes if WasTouched is false.
You can increase sensitivity by changing Division of hardcoded 10. Just create TouchSensitivity float variable and pin it there.
Last thing you need to do is to add Controls switch to PC mouse. So PC controls will work as well.
Result
For now we aren't moving camera a lot but later there will be challenge here, don't worry:)
For now we aren't moving camera a lot but later there will be challenge here, don't worry:)
Tilt
Touch
In next post I will create Critical Damage system and we will move into Spider polishing because now it's boring to fight with this enemy.
No comments:
Post a Comment