private void FixedUpdate() { if (Input.GetKey(GameManager.GM.forward)) { OM.MoveTo(new Vector3(0, 0, 1)); } if (Input.GetKey(GameManager.GM.backward)) { OM.MoveTo(new Vector3(0, 0, -1)); } if (Input.GetKey(GameManager.GM.left)) { OM.MoveTo(new Vector3(-1, 0, 0)); } if (Input.GetKey(GameManager.GM.right)) { OM.MoveTo(new Vector3(1, 0, 0)); } if (Input.GetKey(GameManager.GM.jump)) { OM.Jump(); } if (Input.GetKey(GameManager.GM.formChange) && Time.time >= timeToReform) { timeToReform = Time.time + reloadReformTime; SwitchForm(); } //gameObject.transform.SetPositionAndRotation(OM.transform., new Quaternion()); }
// Update is called once per frame void Update() { if (currentBuilding != null) { Vector3 m = Input.mousePosition; Vector3 p = camera.ScreenToWorldPoint(m); currentBuilding.position = new Vector3(p.x, 0, p.z); } if (Input.GetKeyDown(KeyCode.E)) { placeOn ^= true;//Switches from true to false. print("PLACE IS ON" + placeOn); } if (Input.GetKeyDown(KeyCode.B)) { moveOn ^= true; print("MOVE IS ON" + moveOn); } if (Input.GetKeyDown(KeyCode.R)) { selectOn ^= true; print("SELECT IS ON" + selectOn); } if (Input.GetButtonDown("Fire1") && placeOn == true) { currentBuildingNode = mapmaker.NodefromWorldPosition(currentBuilding.position); currentBuildingNode.walkable = false; Instantiate(building, currentBuildingNode.nodeVector, Quaternion.identity); } else if (Input.GetButtonDown("Fire1") && moveOn == true) { currentBuildingNode = mapmaker.NodefromWorldPosition(currentBuilding.position); mapmaker.targetNode = currentBuildingNode; unitmovement.MoveTo(); } else if (Input.GetButtonDown("Fire1") && selectOn == true) { Vector3 m = Input.mousePosition; Vector3 p = camera.ScreenToWorldPoint(m); currentBuilding.position = new Vector3(p.x, 0, p.z); currentBuildingNode = mapmaker.NodefromWorldPosition(currentBuilding.position); unitmovement = currentBuildingNode.currentObj.GetComponent <ObjectMovement>(); //currentBuildingNode.currentObj = ; } if (Input.GetKeyDown(KeyCode.Q)) { if (attackScript != null) { attackScript.Attack(); } } }
public virtual void SetTargetPosition(Vector3 _pos, float _maxSpeed = 3.0f, float _accelator = 0.1f, float speed = 3.0f) { isToggle = true; targetPosition = _pos; objectMovement.MoveTo(_pos, _maxSpeed, _accelator, speed); }