#Implementing Mirror in a prototype (MAJOR desync)
41 messages · Page 1 of 1 (latest)
sorry, its unity 6.2 - in editor
Can you turn off the maximise window on play, and adjust these viewport settings.
I installed 6.2 yesterday, will have a look if mine does the same.
same with free aspect, cant find the maximize but i run on ultrawide so i have scene and game open same time (dont mind the grey boxes :P)
Hmm mines fine, although some new coding errors that might be due to 6.2
🤔
i did have to restart unity after adding mirror, got some coding errors aswell
Even without pressing play, you dont see the examples?
nope
its ok, im abandonning this prototype and starting a new project. something is iffy here 😛
remove that Game tab, and add another
Not sure otherwise, not seen that happen before.
still same
docs state using unity 2020/21 LTS but was updated 10months ago. i saw somewhere saying unity 6000.1 - i assume 6000.2 is ok to use
additional info, the project is a 2D core (URP)
new 6000.2 project. still not rendering properly
after a material conversion some things are visible
i think i see the problem,
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings
examples are based on older worlkflows and systems (render pipelines, inputsystems etc)
am i doing something wrong? following https://mirror-networking.gitbook.io/docs/community-guides/quick-start-guide#part-7
both players have network transform and identity and i s spawned by the network manager. but if this is this janky in localhost its unsable outside.
both players have input as networkbehaviour and if (!isLocalPlayer) return; in input script
im not doing any abilities or anything, just swapping directions and if i spam (repeatedly) A or D and space same time i just teleport somewhere
Written by JesusLuvsYooh / StephenAllenGames.co.uk, edited by James Frowen
in build (at part 19 now) and im still getting the desync/weird behaviour when doing rapid inputs.. it doesnt happen in editor
it only happens in build, never in editor, regardless if i make editor host/client or vice verca
Implementing Mirror in a prototype (MAJOR desync)
Whats your movement code?
https://pastie.io
Paste in here, press save icon, and post URL back
I feel like thats not a mirror thing. but a physics thing, rigidbody movement?
Are you character controller, RB, etc
rigidbody yeah a mix of linearvelocity and force.
the movement code is split across several states and files but linearVelocity for certain move abilities, force for general movement, force for jump
f,ex
private void Jump()
{
Player.input.lastPressedJumpTime = 0;
Player.check.lastOnGroundTimer = 0;
var force = Player.data.jumpForce;
var vel = Player.GetVelocity();
if (vel.y < 0) force -= vel.y;
Player.AddForce(Vector2.up * force, ForceMode2D.Impulse);
}
//player.cs
private Rigidbody2D _rb;
public void AddForce(Vector2 force, ForceMode2D forceMode = ForceMode2D.Force)
{
_rb.AddForce(force, forceMode);
}
//onGroundState.cs
protected override void OnFixedUpdate()
{
Player?.movement?.Move(1);
//TODO JUMP
}
//player.cs
public void Move(float lerpAmount)
{
var vel = player.GetVelocity();
var moveInput = player.input.moveInput;
var targetSpeed = moveInput.x * player.data.runMaxSpeed;
targetSpeed = Mathf.Lerp(vel.x, targetSpeed, lerpAmount);
var isAccelerating = Mathf.Abs(targetSpeed) > Mathf.Epsilon;
var accelRate = isAccelerating ? player.data.runAccelAmount : player.data.runDeccelAmount;
if (player.check.lastOnGroundTimer <= 0)
accelRate *= isAccelerating ? player.data.accelInAir : player.data.deccelInAir;
if (player.data.doConserveMomentum)
{
var isMovingFasterThanTarget =
Mathf.Abs(targetSpeed) > Mathf.Epsilon && Mathf.Abs(vel.x) > Mathf.Abs(targetSpeed);
var velIsApproxTarget = Mathf.Approximately(Mathf.Sign(vel.x), Mathf.Sign(targetSpeed));
if (isMovingFasterThanTarget && velIsApproxTarget && player.check.lastOnGroundTimer <= 0)
accelRate = 0;
}
var speedDif = targetSpeed - vel.x;
var movement = speedDif * accelRate;
player.AddForce(movement * Vector2.right);
}
(its bad, i know xD buddy started the code, i took over and made it more usable :P)