void FixedUpdate() { // Calculate how fast we should be moving Vector3 targetVelocity = Vector3.zero; /*if (horizontal) * {*/ targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0, 0); /*} * else * { * targetVelocity = new Vector3(0, 0, Input.GetAxis("Horizontal")); * }*/ targetVelocity = transform.TransformDirection(targetVelocity); targetVelocity *= speed; //Debug.Log(targetVelocity); // Apply a force that attempts to reach our target velocity Vector3 velocity = _rigidbody.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0; _rigidbody.AddForce(velocityChange, ForceMode.VelocityChange); if (ballManager.ActiveBalls.Count == 0 && ballManager.lives > 0) { //Debug.Log("No active balls"); ball = ballManager.ActivateBall(); if (ball != null) { bs = ball.GetComponent <BallScript>(); bs.bar = this.transform; bs.follow = true; TimerText.Instance.stopTimer(); } } }