I like to start with making my game mobile playable.
The first touch inputs works oke, but only with specific camera perspective.
In the example below the player looks at touch input only below half of the screen.
So touch input above (or the back) of the player doesn’t work.
I use this code right now:
Player.prototype.updateFromScreen = function (screenPosition) {
var depth = 9;
this.cameraEntity.camera.screenToWorld(screenPosition.x, screenPosition.y, depth, this.touchPosition);
// Rotate the player to touch input
this.moveDirection = new pc.Vec3(this.touchPosition.x, player.getPosition().y, this.touchPosition.z);
};
Player.prototype.onTouchStart = function (event) {
if (event.touches.length === 1) {
this.updateFromScreen(event.touches[0]);
//playerIsMoving = true;
}
};
Player.prototype.onTouchMove = function (event) {
this.updateFromScreen(event.touches[0]);
};
Player.prototype.onTouchEnd = function (event) {
if (event.touches.length === 0) {
//playerIsMoving = false;
}
};
Player.prototype.onTouchCancel = function (event) {
if (event.touches.length === 0) {
//playerIsMoving = false;
}
};
Also selecting an inventory item is not working as expected but maybe thats a problem for later.