- Home /
Strange bug, black screen and invalid input position NaN error
Hi, im working on puzzle game in multiplayer and works all well(about all =) ), anyway when i try my game on my computer, i launch editor and pc, mac & linux standlone .exe, all seems to be fine except when i press 'w' or 'a ' or 's' or 'd' movement key in exe for move player, then black screen in game appear immediately on editor and it show this error message:
UnityEngine.Transform:set_position(Vector3) MovementUpdate:UpdateMovement(Vector3, Quaternion) (at Assets/scripts/Network Scripts/MovementUpdate.cs:72) not change nothing if i make vice-versa(client/server - server/client), ever if i press any movement button key, black screen appear and error message is printing(black screen appear only in exe, editor works perfectly in all two case) I try another solution, i build exactly same project in web player, and this time works both(client/server - server/client), without black screen and errors. There is my pc info: - Windows 7 Home Premium Service Pack 1 - HP Pavilion dv6 Notebook PC - Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz 2.00 GHz - 4,00 GB RAM - 64 bit - Kaspersky PURE And this is the script that give me error:(only in exe, of course) using UnityEngine; using System.Collections;transform.position assign attempt for 'Player(Clone)' is not valid. Input position is { NaN, NaN, NaN }.
/// /// This script is attached to the player and it /// ensure that every players position, rotation, and scale, /// are kept up to date across the network ///
public class MovementUpdate : MonoBehaviour {
//Variables Start_
private Vector3 lastPosition; private Quaternion lastRotation; private Transform myTransform;
//Variables End __
// Use this for initialization void Start () { if (networkView.isMine) { _myTransform = transform;
//ensure that everyone sees the player at the correct location //the moment they spawn networkView.RPC("UpdateMovement", RPCMode.OthersBuffered, _myTransform.position, _myTransform.rotation); }
else { enabled = false; } }
// Update is called once per frame void Update () { //if the player has moved at all then fire off an RPC to update the players //position and rotation across the network
if (Vector3.Distance(_myTransform.position, _lastPosition) >= 0.1f) { //Capture the player's position before the RPC is fired off and use this //to determine if the player has moved in the if statement above
_lastPosition = _myTransform.position;
networkView.RPC("UpdateMovement", RPCMode.OthersBuffered, _myTransform.position, _myTransform.rotation); }
if (Quaternion.Angle(_myTransform.rotation, _lastRotation) >= 1) { //Capture the player's rotation before the RPC is fired off and use this //to determine if the player has turned in the if statement above
_lastRotation = _myTransform.rotation;
networkView.RPC("UpdateMovement", RPCMode.OthersBuffered, _myTransform.position, _myTransform.rotation); } }
[RPC] void UpdateMovement(Vector3 newPosition, Quaternion newRotation) { //print(newPosition.ToString()); //print(newRotation.ToString()); transform.position = new Vector3(newPosition.x, newPosition.y, newPosition.z);
transform.rotation = new Quaternion(newRotation.x, newRotation.y, newRotation.z, newRotation.w); } } Thanks for help, i dont know what i can i do. S:
Answer by someone13 · Dec 31, 2013 at 02:24 PM
I was getting this issue in build versions of my game. Check to see if your build has a corrupted resources.assets file. If it does, fix it. The fix for mine, was that I had multiple script files with the same name in both JS and C#.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085747im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Position GameObject to Bottom Left Corner 2 Answers
A node in a childnode? 1 Answer
World to Screen 1 Answer