Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by beyluta · Aug 23, 2015 at 04:51 PM · networkingphoton

how do i use get component in unity 5? the code below is just an example, it's not mine but it's similar and also doesn't work

   MouseLook cameraScript;
  CharacterMotor controllerScript;
  FPSInputController controllerScript2;
  CharacterController charControl;
  GameObject cam;
 
  public void Awake()
  {
      cameraScript = GetComponent<MouseLook>();
      controllerScript = GetComponent<CharacterMotor>();
      controllerScript2 = GetComponent<FPSInputController>();
      charControl = GetComponent<CharacterController>();
  }
 
  public void Start()
  {
      if (photonView.isMine)
      {
          
          cameraScript.enabled = true;
          controllerScript.enabled = true;
          controllerScript2.enabled = true;
          charControl.enabled = true;
      }
      else
      {
          enabled = true;
          cameraScript.enabled = true;
          controllerScript.enabled = true;
          controllerScript2.enabled = true;
          charControl.enabled = true;
      }
Comment
Add comment · Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Positive7 · Aug 23, 2015 at 05:37 PM 0
Share

What do you mean it doesn't work? This code should work fine. What error do you have? Do you have all Component attached in the Inspector?

avatar image beyluta · Aug 23, 2015 at 05:47 PM 0
Share

the names of the scripts turn into red as soon as i type them, and i think it pops up a error, for some reason isn't showing anymore but still doesn't work

avatar image Positive7 · Aug 23, 2015 at 05:50 PM 0
Share

Can you please post example script so we can see what you trying to do?

avatar image beyluta · Aug 23, 2015 at 05:55 PM 0
Share
 using UnityEngine;
 using System.Collections;

  public class Networking : Photon.$$anonymous$$onoBehaviour {
  FirstPersonController Char;

 void Awake() 
 {
     Char = GetComponent<FirstPersonController> ();
 }



 // Use this for initialization
 void Start () {
     PhotonNetwork.ConnectUsingSettings ("RP_v005");

     Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
     Cursor.visible = (false);

     if (photonView.is$$anonymous$$ine)
     {
         Char.enabled = true;
     }
     else
     {
         enabled = true;
         Char.enabled = false;
     }

 }
 
 // Update is called once per frame
 void Update () {
     Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
     Cursor.visible = (false);
 
 }

 void OnGUI() {
     GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
     if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.Escape))
     {
         PhotonNetwork.LoadLevel("$$anonymous$$ain$$anonymous$$enu");
     }
 }


 void OnConnectedTo$$anonymous$$aster() {
     PhotonNetwork.JoinRandomRoom ();
 }

 void OnPhotonRandomJoinFailed() {
     PhotonNetwork.CreateRoom (null);
 }

 void OnJoinedRoom() {
     GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate ("PlayerPrefab", Vector3.zero, Quaternion.identity, 0);
     PhotonNetwork.automaticallySyncScene = true;

 }


}

avatar image Positive7 · Aug 23, 2015 at 07:34 PM 1
Share

And if you move the script to the StandardAssets folder? Or Try using

 using Unity.StandardAsseets

Or something like this. I'm answering from phone so can't test it at the moment.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by beyluta · Aug 23, 2015 at 08:16 PM

It's already in the standardassets, and using unity.standardassets didn't work either

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image beyluta · Aug 23, 2015 at 08:39 PM 0
Share

Other c# scripts seems to work, but not this one

avatar image beyluta · Aug 23, 2015 at 09:19 PM 0
Share

Just need to add namespace UnityStandardAssets.Characters.FirstPerson{ and worked just fine, thanks @Positive7

avatar image Positive7 · Aug 23, 2015 at 09:28 PM 0
Share

Good to hear. I just installed Unity to my traveling Laptop to test it :D It is really slow also I posted one with the namespace before it was just the wrong one :P

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Hi, i've made a multiplayer photon script but it controls every player in the server, how to control only my player? 1 Answer

Getting server browser with photon ? 3 Answers

Unity Networking Cannot Join Match - Room Disappears 1 Answer

Fail to Connect to NetworkServer 1 Answer

Unet not connecting over the internet 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges