Open dicarne opened 2 months ago
also having similar problems, synchronizer visibility needs better documentation
bool MultiplayerSynchronizer::is_visible_to(int p_peer) {
if (visibility_filters.size()) {
Variant arg = p_peer;
const Variant *argv[1] = { &arg };
for (Callable filter : visibility_filters) {
Variant ret;
Callable::CallError err;
filter.callp(argv, 1, ret, err);
ERR_FAIL_COND_V(err.error != Callable::CallError::CALL_OK || ret.get_type() != Variant::BOOL, false);
if (!ret.operator bool()) {
return false;
}
}
}
return peer_visibility.has(0) || peer_visibility.has(p_peer);
}
The relevant source code is as above. It seems that if any filter returns false, it is not visible. If it is public or has been explicitly specified as visible to p_peer, then it is visible. That is, it is visible only when:
Therefore:
When the node is specified as not public, but the filter allows a peer to be visible, and has not been explicitly specified as visible to this peer through set_visibility_for
, this node will not be seen by this peer.
Tested versions
System information
Windows11
Issue description
MultiplayerSynchronizer.add_visibility_filter does not seem to change the visibility of the corresponding peer, even though the filter returns true. I thought that if the filter returns true, it means it is visible, but it is not. Is there something wrong with my understanding?
Steps to reproduce
nodes like this:
MultiplayerSynchronizer setting:
![image](https://github.com/godotengine/godot/assets/10357789/3320a3dc-9314-4f52-8304-2a3dbc60d6cb)
add filter:![image](https://github.com/godotengine/godot/assets/10357789/bea83943-bbfa-4e85-bc62-15bae65c24f0)
check peer's visibility, I think if the visibility filter returns true, then visibility should be true.![image](https://github.com/godotengine/godot/assets/10357789/33ad0164-9121-48ea-a5bd-e50878f1feab)
however, visibility is still false.
code overview
Minimal reproduction project (MRP)
add_visibility_filter.zip