Client Can"t Set Attributes?

Started by Bamdon 2 posts 66 views

Reply on sbox.game
  1. #1
    Bamdon 5
    Hey, i'm trying to set a materials shader attribute from c# using the usual  
    protected override void OnUpdate()
    {
        //supposed to set the model/enemy to a different color when damaged
        //thrown into OnUpdate for purely testing purposes, probs wanna move to an RPC
        //once I figure this out
        Log.Info("Yes this code is running");
    	renderer.SceneObject.Batchable = false;
    	renderer.Attributes.Set( "DamageActive", true);
    }
     as you can see this is not networked at all, its just running locally on each client in a game. But my issue is that for whatever reason, it will not run on the clients not matter what ALTHOUGH it runs on the host just fine. I've tried using rpcs to set it,  tried directly setting  
    		renderer.SceneObject.Attributes.Set( "DamageActive", true);
    , and even transferring ownership just to see if maybe that had anything to do with it, but no luck. Any help would be great, thanks!
  2. #2
    Richard 23,090
     Hey! RenderAttributes aren't networked, so non-host clients won't know to set them unless you replicate the damaged state first using a [Sync] property

    Also watch out for two quick gotchas: renderer.SceneObject can be null on clients for a frame or two (throwing a silent exception) and s&box shaders usually expect an int (1/0) rather than a C# bool