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) { return; }
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));
Input.GetAxis("Horizontal");
Input.GetAxis("Vertical");
vecScale.Set((energy / 200 + 0.95f), (energy / 200 + 0.95f), 1);
transform.localScale = vecScale;
energy -= 0.00000072f * energy * energy;
Answer by Commoble · Mar 05, 2017 at 04:56 PM
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.
Answer by kadirkoca · Jul 14, 2019 at 09:53 AM
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.
Your answer
Follow this Question
Related Questions
How to optimize this scripts ? 2 Answers
void OnPlayerDisconnected(NetworkPlayer player) not being called What am i doing wrong? 1 Answer
Locally disabling GameObjects with network transform components attached. 1 Answer
Multiplayer Hiding Layer just for Local Player 0 Answers
Networking Fps Cameras 0 Answers