http://docs2x.smartfoxserver.com/Exampl ... t-movement
Can this script be modified to allow player movement using the traditional ‘joystick controls’ or left (move player forward and backward) and right (look up and down) thumb presses on an iPhone instead of keyboard presses as originally setup in the script?
Thank you in advance
SCRIPT (Player Controller using the Keyboard Convert to iPhone Left and Right Joystick Controls)
Code: Select all
[code]using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float forwardSpeed = 10;
public float backwardSpeed = 8;
public float rotationSpeed = 40;
// Dirty flag for checking if movement was made or not
public bool MovementDirty {get; set;}
void Start() {
MovementDirty = false;
}
void Update () {
// Forward/backward makes player model move
float translation = Input.GetAxis("Vertical");
if (translation != 0) {
this.transform.Translate(0, 0, translation * Time.deltaTime * forwardSpeed);
MovementDirty = true;
}
// Left/right makes player model rotate around own axis
float rotation = Input.GetAxis("Horizontal");
if (rotation != 0) {
this.transform.Rotate(Vector3.up, rotation * Time.deltaTime * rotationSpeed);
MovementDirty = true;
}
}
}