I everyone, i’m making like a Multiplayer PacMan for fun.
And i need to know if this is possible to control one PacMan with ‘‘Arrows key’’ and the other one with ‘‘WASD key’’…
plz help me, you can take a look on my script (JavaScript) :
var speed = 13;
var jumpSpeed = 8.0;
var gravity = 20.0;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
function FixedUpdate() {
if (grounded) {
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
//For Gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move character
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) != 0;
}
@script RequireComponent(CharacterController)