Giter VIP home page Giter VIP logo

Comments (4)

BrianWiz avatar BrianWiz commented on May 18, 2024

@baflink
I've tested with the latest commit and something still isn't right. It seems like field change events now fire if an RPC is sent from the client. Though I can't quite tell for sure, but I'm pretty sure that's what's happening. Or maybe it's receiving any field updates from the server causing them to fire?

For example I have a uint, I set it once on the server and only once, yet when I move, it's change event seems to fire, I've done a find in all files to double check I'm not setting it anywhere else.

I'll keep investigating.

EDIT:
Yeah, I'm pretty sure it's when another field(s) is updated, it fires the event for every field, even fields that haven't been updated.

from forgenetworkingremastered.

BrentFarris avatar BrentFarris commented on May 18, 2024

@BrianWiz Can you try with the newest NetworkObjectTemplate.txt on develop?

from forgenetworkingremastered.

BrianWiz avatar BrianWiz commented on May 18, 2024

@baflink Finally got around to testing this. There is still a problem.

I've got two fields, one is "position" (Vector2), one is "test" (int), both have Interpolation off. I set test once in NetworkStart(), and I set position in Update();

The result is that the testChanged event fires every time position is changed. So it looks like if any field is changed, it thinks they all changed. I confirmed this by commenting out the line that sets the position in Update();

Here's my entire class(es) so you know I'm not doing anything weird.

using UnityEngine;
using BeardedManStudios.Forge.Networking;
using BeardedManStudios.Forge.Networking.Unity;
using BeardedManStudios.Forge.Networking.Generated;

public class Grenade : Projectile
{
    protected override void NetworkStart()
    {
        base.NetworkStart();

        if (networkObject.IsServer)
        {
            networkObject.test = 2;
        }
        else
        {
            networkObject.testChanged += TestChanged;
        }
    }

    void Update()
    {
        if (networkObject != null)
        {
            if (networkObject.IsServer)
            {
                networkObject.position = transform.position;
            }
        }
    }

    private void TestChanged(int test, ulong timestamp)
    {
        Debug.Log("test");
    }
}

using UnityEngine;
using BeardedManStudios.Forge.Networking;
using BeardedManStudios.Forge.Networking.Unity;
using BeardedManStudios.Forge.Networking.Generated;

public class Projectile : ProjectileBehavior
{

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

    public virtual void MoveProjectile(Vector3 direction)
    {
      //  GetComponent<Rigidbody>().AddForce(direction * force, ForceMode.Impulse);
    }
}

from forgenetworkingremastered.

BrianWiz avatar BrianWiz commented on May 18, 2024

@baflink So it looks like on the server, in SerializeDirtyFields(), it returns dirtyFieldsData with fields that shouldn't actually be dirty.

So it looks like if any field is dirty, it sends them all of them over in HeartBeat() on NetworkObject.cs. If none are dirty, it doesn't send anything as expected.

from forgenetworkingremastered.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.