#Implementing Mirror in a prototype (MAJOR desync)

41 messages · Page 1 of 1 (latest)

granite tree
#

topdownshooter does play audio and i can hear movement and shooting etc but no visuals

tawdry bay
#

Wonderful.

#

Which Unity version?

#

Is this in editor, or build?

granite tree
#

sorry, its unity 6.2 - in editor

tawdry bay
#

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.

granite tree
#

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)

tawdry bay
#

Your scale is 1.5, try 1

granite tree
#

1.5 is lowest 😛

#

unless i lock resolution (fex full HD 1080p)

tawdry bay
#

Hmm mines fine, although some new coding errors that might be due to 6.2

granite tree
tawdry bay
#

🤔

granite tree
tawdry bay
#

Even without pressing play, you dont see the examples?

granite tree
#

nope

tawdry bay
granite tree
#

its ok, im abandonning this prototype and starting a new project. something is iffy here 😛

tawdry bay
#

remove that Game tab, and add another

#

Not sure otherwise, not seen that happen before.

granite tree
#

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)

granite tree
#

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)

granite tree
#

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

granite tree
#

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

granite tree
#

Implementing Mirror in a prototype (MAJOR desync)

tawdry bay
#

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

granite tree
#
    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)