cryptomax
cryptomax7mo ago

Possible option to force firing updated model event

Not sure if there are technical difficulties with doing something like this, but to have an event (or maybe just a property setting) that would fire the event if the model was sent an update even if the model didn't change value. This would make it so you could easily use a simple int to continously play various sound effects or trigger various animations from just an int becuase it could keep firing?
10 Replies
cryptomax
cryptomaxOP7mo ago
I guess the recommended approach for handling those is probably a realtime set and you add to it to handle various things like that, (which i've done) but that is a bit more complicated to set up than just a single int script that could process the value and just keep doing the desired item regardless of repeats easy use case for me is just an animation trigger syncer that you just set ints to play the various animations, but playing various sound effects would be easier that way as well
Andrei Vaduva
Andrei Vaduva7mo ago
isn't this possible with RealtimeCallbackAttribute?
[RealtimeModel]
public partial class MatchmakingModel
{
[RealtimeProperty(1, true)]
private int value;

public delegate void ModelUpdatedHandler();
public event ModelUpdatedHandler OnModelUpdatedHandler;

[RealtimeCallback(RealtimeModelEvent.OnDidReadProperties)]
public void OnModelUpdatedEvent(PropertyChangeSet changes)
{
OnModelUpdatedHandler?.Invoke();
}
}
[RealtimeModel]
public partial class MatchmakingModel
{
[RealtimeProperty(1, true)]
private int value;

public delegate void ModelUpdatedHandler();
public event ModelUpdatedHandler OnModelUpdatedHandler;

[RealtimeCallback(RealtimeModelEvent.OnDidReadProperties)]
public void OnModelUpdatedEvent(PropertyChangeSet changes)
{
OnModelUpdatedHandler?.Invoke();
}
}
this will trigger OnModelUpdated everytime the model read properties from the remote model, basically each network frame. is this what you are looking for?
cryptomax
cryptomaxOP7mo ago
possibly yeah! but does this fire every time even if hte model doesn't change?
Mechabit
Mechabit7mo ago
there's an attribute to skip the equality check if that's what you're after
cryptomax
cryptomaxOP7mo ago
well that would do it do then!
Mechabit
Mechabit7mo ago
it was added in 2.9.3 RealtimePropertyAttribute(uint propertyID, bool reliable, bool createDidChangeEvent = false, bool includeEqualityCheck = true) set the last one to false it will send an update even if the int didn't change
cryptomax
cryptomaxOP7mo ago
!!! thank you! why do I feel liek I can't easily find this in the documentation
Mechabit
Mechabit7mo ago
it's not in there poke them to updat it
cryptomax
cryptomaxOP7mo ago
fairly new atribute I suppose
Mechabit
Mechabit7mo ago
the docs need some love too