public class BSMoving : MonoBehaviour
{
public GameObject person;
public Vector3 camdirection;
public Vector3 moveVector = Vector3.right;
public float speed = 30f;
public bool inmoving;
public bool inmovingR = true;
void Start()
{
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
inmoving = !inmoving;
if (Input.GetKeyDown(KeyCode.Mouse1))
{
camdirection = new Vector3(GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().transform.position.x, GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().transform.position.y, GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().transform.position.z);
GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().transform.position = new Vector3(-camdirection.x, camdirection.y, camdirection.z);
inmovingR = !inmovingR;
}
if (inmovingR && inmoving)
{
person.transform.Translate(moveVector * speed * Time.deltaTime);
}
if (!inmovingR && inmoving)
{
person.transform.Translate(-moveVector * speed * Time.deltaTime);
}
}
}