I decided to try out a build of the game (an FPS) on my PC, and to see what the requirements for the game would be so far. (by using VMWare player)
However, I came across a problem… I can’t move.
The player starts off above the ground, I did this to test the gravity, and I stay in the air!
The mouse and the shooting, but I can’t move and the gravity is non existent.
I’m also getting this error in the log on the bottom-left: “Gamename/Gamename_Data/mainData is corrupted! Remove it and launch unity again! [Position out of bounds! 34308 > 34304]”.
How do I fix this problem?
Also, how can I get rid of the mouse pointer in the game build?
EDIT: The problem seems to be the FPS Input Controller script I have, because all the thing I couldn’t do in the build is handled by this script, here’s the code (It’s in C#):
using UnityEngine;
using System.Collections;
public class FPSInputController : MonoBehaviour {
public float speed = 100;
public float jumpSpeed = 0;
public Vector3 moveDirection = Vector3.zero;
public float gravity = 200;
public bool grounded = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if (grounded)
{
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection*= speed;
}
if (grounded)
{
if(Input.GetButtonDown("Jump"))
{
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
var controller = GetComponent<CharacterController>();
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) !=0;
}
}