Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by joranc · Jun 23, 2015 at 01:15 PM · where-to-startcs0428

I get an error for a reason i dont know

This error : Assets/Multiplayer_manager.cs(58,9): error CS0428: Cannot convert method group GetComponent' to non-delegate type UnityEngine.GameObject'. Consider using parentheses to invoke the method

 using UnityEngine;
 using System.Collections;
 
 public class Multiplayer_manager : MonoBehaviour {
 
     public static GameObject Myplayer;
     public static GameObject Myplayer2;
 
     void Start () {
 
         GameObject Myplayer = GameObject.FindGameObjectWithTag ("Enemy");
 
         Connect ();
     }

 
 
     void Connect() {
         PhotonNetwork.ConnectUsingSettings( "V.02" );
     }
 
 
     void OnJoinedLobby() {
         Debug.Log ("OnJoinedLobby");
         PhotonNetwork.JoinRandomRoom ();
     }
 
 
 
     void Update () {
     
     }
 
 
 void CreateRoom () {
 
 
     }
 
  void OnPhotonCreateGameFailed() {
          
         return;
     }
     void OnPhotonRandomJoinFailed() {
         Debug.Log ("OnPhotonRandomJoinFailed");
         PhotonNetwork.CreateRoom( null );
         Debug.Log ("Roomname created");
     }
 
     void OnJoinedRoom() {
         Debug.Log ("OnJoinedRoom");
 
     Myplayer = Myplayer.GetComponent<Birdmovement>;
  
         Debug.Log (Myplayer);
     }
 
 }

Comment
Add comment · Show 1
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 Graham-Dunnett ♦♦ · Jun 23, 2015 at 01:17 PM 0
Share

I a) formatted your script for you. Please read the FAQ and watch the tutorial video to learn how to do this.

b) added the tag cs0428 to your question. This will help others find the problem.

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Graham-Dunnett · Jun 23, 2015 at 01:21 PM

The error is line 53. Not sure why your compiler error has a different line - probably related to how the code is structured.

Line 53 says "grab the Birdmovement component and assign it to the GameObject called Myplayer. These types are different.

Comment
Add comment · Show 1 · 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 joranc · Jun 23, 2015 at 11:16 PM 0
Share

The thing i want to do is like you have 2 players with 2 scripts (same) and if tag , if joined a room if tag = enemy then deactivate the enemys movement script "Birdmovement" thats what i want to acomplish.

avatar image
1

Answer by Grimbyte · Jun 24, 2015 at 10:37 AM

  Myplayer = Myplayer.GetComponent<Birdmovement>();
Comment
Add comment · 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
0

Answer by joranc · Jun 24, 2015 at 07:16 AM

I want to like if joined then if tag = "enemy" get the bridmovement script component disable it

Comment
Add comment · 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
0

Answer by DiegoSLTS · Jun 24, 2015 at 12:11 AM

One problem, like Graham said, is that you're using:

 GetComponent<Birdmovement>

which returns a Birdmovement object and are storing it into a GameObject variable.

The other problem (the one your error message is telling you about) is that you forgot the parenthesis in that line. Without the parenthesis instead of calling a method you're trying to use that method as a delegate.

Create another variable of type Birdmovement and change line 53 to:

 ThatNewVariable = Myplayer.GetComponent<Birdmovement>();
Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

New to Unity, Noob 3 Answers

Making the leap - How to get into Unity development? 3 Answers

Is it possible to start making a game without any experience in programming? 5 Answers

What does Unity need? 1 Answer

Making my first game? 3 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