- Home /
How to change default FirstPersonController walkspeed from other script?
i need to only change the walk/runspeed of the playercontroller cause the player still needs to look around. code
if (entered == true) {
transform.position = seat.transform.position;
this.transform.GetComponent<FirstPersonController> ();
FirstPersonController.walkspeed 0f;
}
i have looked around i and still do not know why this isnt working
Answer by SPOTNINJADUD7890 · Nov 05, 2016 at 11:59 PM
nvm found my own awnser
public UnityStandardAssets.Characters.FirstPerson.FirstPersonController controller;
controller.m_WalkSpeed = 3f;
controller.m_RunSpeed = 8f;
ty for the help though
Answer by iAmAwsum · Nov 05, 2016 at 06:50 PM
Assuming the variable in the default FirstPersonController for walk speed is called "walkspeed" you can try:
GameObject.Find("Player").GetComponent().walkspeed = 0f;
Player = GameObject which includes the FirstPersonController Script.
could you have a way of doing it not finding everything? This is a multiplayer game and needs to only access the one player.
also i tried this code
GameObject.Find("Player").GetComponent<FirstPersonController>().walkspeed = 0f;
and its giving me this error
error CS1061: Type UnityStandardAssets.Characters.FirstPerson.FirstPersonController' does not contain a definition for
walkspeed' and no extension method walkspeed' of type
UnityStandardAssets.Characters.FirstPerson.FirstPersonController' could be found (are you missing a using directive or an assembly reference?)
Your answer
Follow this Question
Related Questions
Problem with PhotonView.RPC 1 Answer
PhotonNetwork Scripted Spawn player 0 Answers
I get 2 errors every time iI run my program. Help! 1 Answer
Photon wont sync for the masterclient. 1 Answer
Cube Gravity - Apply Gravity to a Curve 0 Answers