Hope this One is Easy

Hi All

The following script is provided by SmartFox to control the movement of a player using the keyboard:


Can this script be modified to allow player movement using the traditional ‘joystick controls’ or left (move forward and back) 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)

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;

Yes it can!
Sorry for being blunt, but if you really want to know how to do so… learn to read code.

Happy Holidays!