how to do FirstPersonController, does not move with the keys, else with the mouse?, with a script that I have developed, and collision too operate, because if I add the component of motion and move only with the mouse, FirstPersonController not collides, and I just want to change the current keys for mouse, replace keys, a,s,d,w, and arrows, for only mouse, this is my code. please help me !!!
sing UnityEngine; using System.Collections;
public class MoveFisrtPersonMouse : MonoBehaviour {
public float velocidad = 5;
public float velocityRotation = 0.3f;
private bool move = false;
private float mouseX;
private float mouseY;
// Update is called once per frame
void Update () {
if(Input.GetMouseButtonDown(0)){
move = true;
mouseX = Input.mousePosition.x;
mouseY = Input.mousePosition.y;
}
if(Input.GetMouseButtonUp(0)){
move=false;
mouseX = 0;
mouseY = 0;
}
if(move){
if(mouseX + 100 < Input.mousePosition.x){
transform.eulerAngles = new Vector3(transform.eulerAngles.x,transform.eulerAngles.y+velocityRotation,transform.eulerAngles.z);
}
if(mouseX - 100 > Input.mousePosition.x){
transform.eulerAngles = new Vector3(transform.eulerAngles.x,transform.eulerAngles.y-velocityRotation,transform.eulerAngles.z);
}
if(mouseY + 100 < Input.mousePosition.y){
transform.Translate(Vector3.forward * (Time.deltaTime*velocidad));
}
if(mouseY - 100 > Input.mousePosition.y){
transform.Translate(Vector3.forward * (Time.deltaTime*-velocidad));
}
}
}
}