Trying to add a second game controller (Mac)

NEWBIE - I am doing a simple Pacman based on the “Roll a ball” Tutorial. In lieu of adding AI, I want to add a second player controller for someone else to control the ghost. I’ve changed the Input settings for Horizontal1 and Vertical1 for Pacman to the arrow keys, and Horizontal2 and Vertical2 for the ghost to a-s-d-w.

Pacman works great, rolls around like a champ. The ghost immediately starts sinking below the floor, and even if it weren’t it doesn’t appear to be moving per a-s-d-w.

Ghost and Pacman seem identical, both have colliders, similar controllers, etc.



First thing is you have no value set for speed. I wouldn’t bother using a character controller as adding a script to a game object with any collider has the same effect.
The code below attached to the ghost should get you moving towards the top of the screen (assuming that your board is oriented along the Z axis). You should be able to set up the rest of you controls using the same code for each direction. (E.G. Vector3.back, vector3.right, etc.)

using UnityEngine;
using System.Collections;

public class pacmanP2controller : MonoBehaviour {

	void FixedUpdate ()
		PC2Movement ();

	void PC2Movement()
		float speed = 1f;
		float Move = Input.GetAxis("Vertical2");
		float Strafe = Input.GetAxis("Horizontal2") ;

		if (Move > 0) 
				rigidbody.MovePosition(rigidbody.position + Vector3.forward * speed * Time.deltaTime);
			Debug.Log ("Forward");