[c#] A little script help plz ... Cannot implicitly convert type `double' to `float'

Not quite sure why I’m getting “Cannot implicitly convert type double' to float’” errors for the lines marked …

Any ideas?

      public class myProjectile : MonoBehaviour {
            
            Collider bullet1; // Collider passed in
            float rads1;
            float ForceX1;
            float ForceY1;
            
            void  FixedUpdate (){
            
                 if (theTouch.phase == TouchPhase.Ended){
                     rads1 = Math.Atan2( targetItem.transform.position.y - bullet1.transform.position.y, 
                             targetItem.transform.position.x - bullet1.transform.position.x);  /// <- error
                     ForceX1 = Math.Cos(rads1)*1000.0f;  /// <- error
                     ForceY1 = Math.Sin(rads1)*1000.0f;  /// <- error
                     bullet1.rigidbody.AddForce (ForceX1,ForceY1 , 0.0f);
                  }
              }
        }

System.Math functions return doubles, not floats. Use Unity’s Mathf functions instead, since they return floats. If you use System.Math, then you have to cast the double to float.

By the way, that code shouldn’t be using touch phase input in FixedUpdate. TouchPhase.Ended might not occur during the frame in which FixedUpdate fires, in which case you’ll miss the event.