- Home /
Updating rotation of client not working - strange error
transform.rotation assign attempt for 'Player Multi(Clone)' is not valid. Input rotation is { NaN, NaN, NaN, NaN }. UnityEngine.Transform:set_rotation(Quaternion) PlayerTransformSync:LerpRotation() (at Assets/Scripts/PlayerTransformSync.cs:57) PlayerTransformSync:Update() (at Assets/Scripts/PlayerTransformSync.cs:26)
What does this mean? I have been trying to fix this for an hour, eventually I just gave in and decided to ask a question.
I tried several things, including changing how i rotate the player, etc.
Code:
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class PlayerTransformSync : NetworkBehaviour {
[SyncVar]
private Vector3 syncPos;
[SyncVar]
private Quaternion syncRot;
[SerializeField]
private float lerpRate;
[SerializeField]
private float moveThreshold;
[SerializeField]
private float angularThreshold;
void Update () {
if (isLocalPlayer)
{
TransmitTransform ();
}
else
{
LerpPosition ();
LerpRotation ();
}
}
[Command]
void CmdProvidePositionToServer () {
syncPos = transform.position;
}
[Command]
void CmdProvideRotationToServer () {
syncRot = transform.rotation;
}
[ClientCallback]
void TransmitTransform () {
if (Vector3.Distance (transform.position, syncPos) > moveThreshold)
{
CmdProvidePositionToServer ();
}
if (Quaternion.Angle (transform.rotation, syncRot) > angularThreshold)
{
CmdProvideRotationToServer ();
}
}
void LerpPosition () {
transform.position = Vector3.Lerp (transform.position, syncPos, lerpRate);
}
void LerpRotation () {
transform.rotation = Quaternion.Lerp (transform.rotation, syncRot, lerpRate);
}
}
The error is in the question. I'm heading out for a bit but I will be able to answer responses as long as it doesn't require my computer. otherwise I will comment when I'm back.
I am back now, and ready to answer any and all questions!
I still am in search for an answer, would be nice if someone pointed me in the right direction...
Your answer
Follow this Question
Related Questions
How can I rotate my player to look at the direction my Joystick is pointing to? (Top-Down 2D) 3 Answers
Set rotation of a transform 2 Answers
How do I make gameObject.transform.rotation.z equal to a set float value? 2 Answers
How to rotate a tank turret and gun? 2 Answers
Rotation Angle not precise 1 Answer