How to fix: transform.position assign attempt for 'Player(Clone)' is not valid. Input position is { NaN, NaN, NaN }. UnityEngine.Transform:Translate(Vector3) FloatingPlayer2DController:Update() (at Assets/FloatingPlayer2DController.cs:59)

Hello , I’ll have to optimize that code(for multiplayer realization) ,thank you very much :3 :

void Update()
if (!isLocalPlayer)

    mousePosition = Input.mousePosition;
    mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
    mousePosition -= (Vector2)transform.position;
    quotient = Mathf.Sqrt(mousePosition.x * mousePosition.x + mousePosition.y * mousePosition.y) / delta;
    mousePosition /= quotient;
    transform.Translate(mousePosition * Time.deltaTime);   //59 line 
    Mathf.Pow(energy, Mathf.Log(2, 0.1f));

    vecScale.Set((energy / 200 + 0.95f), (energy / 200 + 0.95f), 1);
    transform.localScale = vecScale;
    energy -= 0.00000072f * energy * energy;

Every time you divide, make sure you’re not dividing by zero. Just in the code above, this can happen if the mouse position at 0 on either axis, or if delta is 0.

Or maybe you use Rectangle Transform for Player(Clone) and editor already sets pos, scale etc. in this situation you cannot change them manually, i mean via codes.