void FixedUpdate() { float moveHorizontal = getAngleHorisontal_X(); float moveVertical = getAngleVertical_Y(); goTo = calculateBallSideMove(moveHorizontal, moveVertical); Vector3 movement = getMovmentVector(goTo); player.AddForce(movement * speed * Time.deltaTime); lastMove = goTo; // Debug.Log(this.transform.position); }
Vector3 getMovmentVector(MOVE_TO goTo) { if (goTo == MOVE_TO.LEFT) { return(new Vector3(1.0f, 0.0f, 0.0f)); } if (goTo == MOVE_TO.RIGHT) { return(new Vector3(-1.0f, 0.0f, 0.0f)); } if (goTo == MOVE_TO.UP) { return(new Vector3(0.0f, 0.0f, -1.0f)); } return(new Vector3(0.0f, 0.0f, 1.0f)); }