change FPS walking speed

hey everyone!

so im completely new in c# and this might seem like a total newb question but anyhow hope you can help me out.

I need to change the speed of my FPS character when she’s in water.
I managed so far to access the FPS preset script, make certain values public and add other sounds to the footstep when shes in water.

I have the feeling i would need to do smth alä the same but im just not really sure how to set up the code for speed going from 5 to 2.

void OnTriggerEnter (Collider other)
{

	if (other.gameObject.tag == "Player") {
		FPC = other.gameObject.GetComponentInParent<FirstPersonController> ();

		if (this.gameObject.tag == "Water") {
			FPC.m_FootstepSounds = WaterFootsteps;
		}

	}

}

void OnTriggerExit(Collider other)
{
	FPC = other.gameObject.GetComponentInParent<FirstPersonController> ();

	if (other.gameObject.tag == "Player")
	{
		FPC.m_FootstepSounds = StandardFootsteps;

	}

}

}

can anyone help me out on this one? Im not so good with this yet, so I need quite simple and clear explenation :wink:

many thanks in advance!

you can simply change the speed when trigger with water.

FPC = other.gameObject.GetComponentInParent<FirstPersonController> ();
FPC .m_WalkSpeed = 3f;
FPC .m_RunSpeed = 8f;

The code is just example call the variable with the name which already declare in your FirstPersonController Script.

amazing! thanks! now it works :slight_smile:

I had to go into FirstPersonController.cs and change the variables I wanted to control to public for this to work.