hi, im wanna make an online game now i have some problems. i need to get the rotation in eulerangles with tranform.eulerAngles but its a static value its dont change when i debug the rotation both tranform rotation and transform eulerangles localeulerangles nothing work. i get everytime the same 0, 322.22, 00 some times when i rotate 10 time its goes to (0, 322.18, 0) but only in the script where i need to know the rotation its not working in all other scripts its work what a strange s***. heres the script where i cant get the correct rotation. i tried to write something like otherscript.transform.eulerAngles but its dont work too.
public override void SimulateController()
{
IPlayerCommandInput input = PlayerCommand.Create();
input.fire = shooting;
input.reload = reload;
input.Forward = direction.y;
input.Sideward = direction.x;
input.AimTarget = AimTarget.position;
input.Yaw = yaw.y;
Debug.LogWarning("Euler in Deg " + gameObject.transform.eulerAngles.y + " Full Euler " + yaw + " dire " + direction);
entity.QueueInput(input);
weaponHandler.ExecuteCommand(shooting, reload, seed);
}
public void SetState(Vector3 pos, float rot)
{
//if (Mathf.Abs(rot - transform.eulerAngles.y) > 2f)
// transform.rotation = Quaternion.Euler(0, rot, 0);
if (firstState)
{
if(pos != Vector3.zero)
{
transform.position = pos;
firstState = false;
lastServerPos = Vector3.zero;
}
}
else
{
if (pos != Vector3.zero)
lastServerPos = pos;
}
transform.position += (lastServerPos - transform.position) / 2;
_state.position = pos;
_state.rotation = rot;
}
public struct State
{
public Vector3 position;
public float rotation;
public bool isGrounded;
}
public State _state;
public override void SimulateOwner()
{
state.isCrouching = isCrouching;
}
public override void ExecuteCommand(Command command, bool resetState)
{
PlayerCommand cmd = (PlayerCommand)command;
if (!resetState)
{
if (!entity.HasControl)
{
weaponHandler.ExecuteCommand(cmd.Input.fire, cmd.Input.reload, seed);
Move(new Vector2(cmd.Input.Sideward, cmd.Input.Forward));
AimTarget.transform.position = cmd.Input.AimTarget;
//transform.rotation = Quaternion.Euler(0, cmd.Input.Yaw, 0);
}
cmd.Result.Position = transform.position;
cmd.Result.Rotation = transform.eulerAngles.y;
cmd.Result.Velocity = velocity;
cmd.Result.isGrounded = grounded;
cmd.Result.AimTargetResult = AimTarget.position;
}
else
{
SetState(cmd.Result.Position, cmd.Result.Rotation);
}
}
void Jump(bool jump)
{
// Debug.LogWarning(jump);
}
private void Update()
{
// yaw = transform.eulerAngles;
// PollKeys();
if (entity.HasControl)
{
Debug.LogWarning("UPDATE " + yaw + "eulen " + animator.transform.eulerAngles + "pos" + transform.position);
yaw = animator.transform.eulerAngles;
state.BlendX = direction.x;
state.BlendY = direction.y;
RotatePlayer();
}
if (entity.IsOwner)
{
state.RotationValue = RotatePlayer();
seed = Random.Range(1, 1024);
//Move();
AnimatorController();
//Sensor();
#region ApplyGravity
if (c_controller.isGrounded && velocity.y < 0) velocity.y = 0;
velocity.y += Physics.gravity.y * BoltNetwork.FrameDeltaTime;
#endregion
}
#region Change Body/Head weight
if (useCar.playerState != UseCar.State.Free || animator.GetCurrentAnimatorStateInfo(3).IsName("Reloading"))
{
weightMultiplier = 0;
// headWeight = 0f;
}
else
{
weightMultiplier = 1;
// headWeight = 1f;
}
#endregion
smoothedBodyWeight = Mathf.SmoothDamp(smoothedBodyWeight, bodyWeight, ref bodyWeightVelocity, weightSmoothness);
smoothedHeadWeight = Mathf.SmoothDamp(smoothedHeadWeight, headWeight, ref headWeightVelocity, weightSmoothness);
//bodyWeight = (animator.GetCurrentAnimatorStateInfo(3).IsName("Reloading") || useCar.playerState != UseCar.State.Free) ? 0 : 1;
}
i use photon bolt and when i put the debug log in other scripts update function its work
[Header("Ammo Display")]
private Text magAmmoText;
private Text totalAmmoText;
[Header("Hit Feedback")]
public Canvas hitFeedbackCanvas;
public float hitFeedbackDuration = 2f;
public float hitFeedbackForce = 50f;
public override void Attached()
{
if (entity.HasControl)
{
canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
Killtext = GameObject.Find("KillText").GetComponent<Text>();
healthText = GameObject.Find("HealthText").GetComponent<Text>();
magAmmoText = GameObject.Find("CurrentAmmoText").GetComponent<Text>();
totalAmmoText = GameObject.Find("TotalAmmoText").GetComponent<Text>();
cam = Camera.main;
}
playerStats = GetComponent<PlayerStats>();
}
private void Update()
{
Debug.LogWarning("UI Contrull" + transform.eulerAngles);
}
public void HitFeedback(Vector3 hitpoint, int damage)
{
Quaternion rot = Quaternion.LookRotation(hitpoint - cam.transform.position);
Canvas killCanvas = Instantiate(hitFeedbackCanvas, hitpoint, rot);
killCanvas.transform.position = killCanvas.transform.position - killCanvas.transform.forward;
killCanvas.GetComponentInChildren<Text>().text = damage.ToString();
Vector2 forceDir = new Vector2(Random.Range(-30, 30), hitFeedbackForce);
killCanvas.GetComponent<Rigidbody2D>().AddForce(forceDir);
Destroy(killCanvas.gameObject, hitFeedbackDuration);
}
public void UpdateKillScreen(NetworkId killerID, NetworkId killedsID)
{
if (entity.HasControl)
Killtext.text = killerID + "kill" + entity.NetworkId;
}
s*** like this only happens to me i dont know how something like this can happen, and only in the script here i need to know the rotation only in this script its not working whats that ? in all other script its working