Hi everyone, i’m making like a Multiplayer PacMan for fun. but i need to make one pacman movement with ‘‘WASD keys’’ and one with ‘‘Arrow Keys’’ but, I always got error error… what is it ? plz… :
var gravity = 20.0;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
function FixedUpdate() {
if (grounded) {
if (Input.GetKey (KeyCode.W))
{
moveDirection = Vector3(Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
}
if (Input.GetKey (KeyCode.A))
{
moveDirection = Vector3(Input.GetAxis("Horizontal"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
}
if (Input.GetKey (KeyCode.S))
{
moveDirection = Vector3(Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
}
if (Input.GetKey (KeyCode.D))
{
moveDirection = Vector3(Input.GetAxis("Horizontal"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
}
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
//Gravity
moveDirection.y -= gravity * Time.deltaTime;
//Character
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) != 0;
}
@script RequireComponent(CharacterController)
My error : BCE0024: The type ‘UnityEngine.Vector3’ does not have a visible constructor that matches the argument list ‘(float)’.