Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Change Hand Color During Gameplay? UpdateAvatarMaterial

I'm a super n00b building my first VR app using Unity 2017. Apologies if I'm missing something obvious or lacking a basic skill to solve my problem! But any help would be greatly appreciated!

I'm working on a scene that uses Touch controllers and Local Avatar & OVR Avatar Hand -- it's a simple first person scene in which the player can see her hands, control them with the Touch controllers, and interact with some objects in the scene. I'd like to be able to trigger changes to the hand color during play. Can't figure out how.

So far I've been able to change the hand color by editing  UpdateAvatarMaterial, which is in OvrAvatarRenderComponent.cs. I changed mat.SetColor to a hard-coded color (in this case, blue). You can see where I commented out the original line and then added my change:  

protected void UpdateAvatarMaterial(Material mat, ovrAvatarMaterialState matState)

What I don't know how to do is use mat.SetColor  from a different script. Like, if the hand collides with a snow bank, detect the collision and change the hand color. I'm of course happy to go about this an entirely different way if somebody has a good idea.



  • MikeFMikeF Posts: 988
    What i've done in the past is to set a public bool in the OVR script called "OverrideMaterial" with a return flag at the top of the material update method when it's true. Whenever i want to change some aspect of the material or swap it entirely, set that bool to true through whatever script you want, then you can change your properties or material without the OVR script reverting your changes since it updates every frame. 
Sign In or Register to comment.