void OnStateWalkOnce() { Debug.Log("walk:" + this.gameObject.name); if (_moveBase != null) { _moveBase.Move(); } }
// Update is called once per frame void Update() { if (controller.isGrounded) { OnGrounded.Invoke(); } else { OffGrounded.Invoke(); } CharacterMover.Move(controller); }
void FixedUpdate() { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); /*if(Input.GetKey(KeyCode.W)) { * transform.position += transform.forward * Time.deltaTime * speed; * } else if(Input.GetKey(KeyCode.S)) { * transform.position -= transform.forward * Time.deltaTime * speed; * } else if(Input.GetKey(KeyCode.D)) { * transform.position += transform.right * Time.deltaTime * speed; * } else if(Input.GetKey(KeyCode.A)) { * transform.position -= transform.forward * Time.deltaTime * speed; * }*/ //Inspired by: https://answers.unity.com/questions/616195/how-to-make-an-object-go-the-direction-it-is-facin.html rb.AddForce(movement * speed); //transform.LookAt(focus); //Figure out why it makes the player launch off, how to get movement to be relative to camera rotation CharacterMover.Move(controller); }
private void Update() { CharacterMover.Move(controller); }