Changing FPSController values via C#?

Hello,

I’m trying to change some FPSController values under certain conditions. Primarily when underwater, I have a detection script setup which changes fog colour and such when under a certain y position but want to know how I can reference other Javascript elements from C#.

I have my underwater.cs script attached to my main camera. Here are the things I want to effect:

  • CharacterMotor.js gravity = 0
  • Need some buoyancy, what could I change to simulate this? Gravity = -1 makes you rise but the movement keys make that more apparent. Not really sure what to do?
  • How can I change the character controller so I can move in all directions rather than just left and right?

Just to put this into perspective:

void SetUnderwater () 
		{
            RenderSettings.fogColor = underwaterColor;
            RenderSettings.fogDensity = 0.01f;
		    //CharacterMotor.gravity = 0;
                //Buoyancy
                //Movement directions
            }

Thanks for your time!

I’m no expert on the subject, but I believe you must use the same language to access a specific script, due to C# and JS/US using different syntax. Don’t forget that you can use both languages in a game.