#Need Little help with Reconcile for Prediction

52 messages · Page 1 of 1 (latest)

chilly night
#

New update says I need override CreateReconsile method for prediction.
but code doesnt reach there if i use that.

Here my my corrent code. let me know if i did any mistake

Fishnet Version 4.3.1R.Pro

public struct MoveData : IReplicateData
    {
        public uint SendTick;
        public Vector3 Direction;
        public MoveData(Vector3 dir, uint sentTick)
        {
            this.SendTick = sentTick;
            this.Direction = dir;
            tick = 0;
        }

        private uint tick;
        public void Dispose() { }
        public uint GetTick() => tick;
        public void SetTick(uint value) => tick = value;
    }
    public struct ReconsileData : IReconcileData
    {
        public Vector3 Position;
        public Quaternion Rotation;       

        public ReconsileData(Vector3 pos, Quaternion rot)
        {
            this.Position = pos;
            this.Rotation = rot;            
            tick = 0;
        }

        private uint tick;
        public void Dispose() { }
        public uint GetTick() => tick;
        public void SetTick(uint value) => tick = value;
    }
#
private MoveData GetInputs()
    {
        if (!IsOwner)
            return default;

        if (canMove.Value == true)
        {
            float horizontal = NewInputHandler.GetInputValue<Vector2>("Move").x;
            float vertical = NewInputHandler.GetInputValue<Vector2>("Move").y;

            Vector3 inputdata = Vector3.zero;

            inputdata += new Vector3(horizontal, 0, vertical);

            if (inputdata.sqrMagnitude > 1)
                inputdata = inputdata.normalized;

            if(inputdata == Vector3.zero)
                return new MoveData(inputdata, 0);
            else
                return new MoveData(inputdata, TimeManager.LocalTick);
        }
        else
        {
            return default;
        }
    }
private void OnTick()
    {
        MoveData md = GetInputs();
        Move(md);

/* Before I was doing like this
        if (IsServerStarted)
        {
            ReconsileData rd = new ReconsileData(Controller.transform.position, Controller.transform.rotation);
            Reconsile(rd);
        }
*/
    }

[Replicate]
    private void Move(MoveData md,ReplicateState state = ReplicateState.Invalid, Channel channel = Channel.Unreliable)
    {
        if (state == ReplicateState.CurrentFuture)
            return;
        Vector3 direction = md.Direction;       
        Controller.Move(direction * speed * (float)TimeManager.TickDelta);        
        
    }
[Reconcile]
    private void Reconsile(ReconsileData rd, Channel channel = Channel.Unreliable)
    {
        print("hello");
        Controller.enabled = false;
        Controller.transform.position = rd.Position;
        Controller.transform.rotation = rd.Rotation;
        Controller.enabled = true;
    }
public override void CreateReconcile()
    {
        base.CreateReconcile();
        
        ReconsileData rd = new ReconsileData(Controller.transform.position, Controller.transform.rotation);
        Reconsile(rd);
    }
elfin trench
#

Hi there, I believe you need to call CreateReconcile where that code was before

chilly night
#

how do i call this?

#

can you give me an code example

elfin trench
#

CreateReconcile();

chilly night
#

will it go to override function ?

elfin trench
#

In the OnTick function where the code used to be

chilly night
#

ahh i see

#

override function confused me i thought it wont go there if i just call it like that

elfin trench
#

Ah, yeah it's a bit confusing

chilly night
#

Thanks a lot @elfin trench . I will test and let you know the update.

#

@elfin trench
ok I have tried it.

private void OnTick(){
    if (IsServerStarted)
    {
        CreateReconcile();
    }
}

public override void CreateReconcile()
{
    base.CreateReconcile();
    print("Hello"); // It is reaching here, printing     
    ReconsileData rd = new   ReconsileData(Controller.transform.position,Controller.transform.rotation);
    Reconsile(rd);
}
[Reconcile]
private void Reconsile(ReconsileData rd, Channel channel = Channel.Unreliable)
{
    print("hello2"); //It is not reaching, not printing      
}
#

still there is issue

#

Also Kindly Check this

elfin trench
elfin trench
chilly night
#

@elfin trench ok i will try . i thought we needed the predicted object . What is it for then ?
Also code is still not reaching to [Reconsile] method

#

I must be doing something wrong here 🙄

#
[Reconcile]
private void Reconsile(ReconsileData rd, Channel channel = Channel.Unreliable)
{
    Debug.Log("hello");  //Code is not reaching Here :(      
}

public override void CreateReconcile()
{
    base.CreateReconcile();
    //Code is reaching Here for sure.
    ReconsileData rd = new ReconsileData(Controller.transform.position, Controller.transform.rotation);
    Reconsile(rd);
}
elfin trench
elfin trench
chilly night
#

@elfin trench Well it was working fine in prediction V1 . v2 i have to figure out somehow.. we might have to wait for @midnight igloo

chilly night
#

@elfin trench Code is reaching to [Reconsile] but on client side. Host can not get the value. also throws an warning "You are not the owner of this object" on client and host. and host is not getting the reconsile value so doesn't move.

elfin trench
chilly night
#

could be the case

#

@elfin trench tested with server and 2 client build. looks like first client is fine . after second client joins it throws the same warning and observer doesnt move.

#

I will come back later and will solve it together with @midnight igloo

#

@elfin trench Thanks for the patience 🙂

chilly night
#

@midnight igloo Whenever you come online please have a look on this. It says "Cannot complete action because you are not the owner of this object" on Host. Other client is fine. although its too jittery movement, Observer is smooth.

midnight igloo
#

What exactly is saying not owner? You have a stack trace? @chilly night

chilly night
#

@midnight igloo @elfin trench
So I have fixed the "Cannot complete action because you are not the owner of this object" Issue, seems I had some mistake in script.
But now that it has no error here are Updates.

  1. Clients movement is not synchronizing.
  2. On Server we can see clients are moving
  3. If I turn on the synchronizations On network transform then it is moving fine.(as far I know we should not turn it on)

I have also Attached all the network settings that I have. Also for now I have turn off the graphic. later I will add it after movement is fixed.
Please have a look and let me know if you have any suggestion. "I've been pulling my hair out and I am almost bald".

elfin trench
chilly night
#

@elfin trench Ok i will change that. and understood the concept now. but why my client is not reconsiling

#

@elfin trench Please see my code also.. is anything wrong with that ?

elfin trench
chilly night
#

@elfin trench not host only.. can you please look at the video i have posted

#

there i have indicated

elfin trench
#

I don't see the video indicating anything about reconciling

chilly night
#

I mean what is happening is in server i can see clients are moving.. but client doesnt see other client moves

elfin trench
#

Isn't that because you disabled the NetworkTransform from syncing movement?

chilly night
#

yes

#

but i should right ?

elfin trench
#

As I said, you need to enable that

chilly night
#

wait let me understand this concept

#

ok but i am not using state forwarding.. so i should not use network transform right ?

elfin trench
#

It's the other way around, is you use state forwarding, then all clients are running the inputs on all the objects and that's moving all the objects correctly. If you don't use it then you need to sync the object's movement from the server to the non owner clients, often with a NetworkTransform

chilly night
#

ahh i see

#

then its working fine but only one issue will be remain if i use like 400 ping .. client doesnt lag there

#

but lets not go there yet.. let me test all this concepts then i will let you know the updates

#

Thanks again @elfin trench . you are the best

#

@elfin trench Working Perfectly now. Thanks a lot. now understood the concept with character controller.