• 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 Tariq-mehmood · Aug 20, 2016 at 06:48 AM · androidunity 5networkingconnection

unity 3d game which is control by an Android app

Dear All What i want to do is to create a 3d car game in w$$anonymous$$ch enemy car is coming from front and you are going against to your enemy and your car can just go toward left or right now every t$$anonymous$$ng will work on your computer/unity(server) w$$anonymous$$ch is control by your android app(client). now i have just implemented t$$anonymous$$s using RPC in unity but the problem is how to connect your server i unity with android app what i basically need is a code or somet$$anonymous$$ng on w$$anonymous$$ch i can work and can get started i am using UiManager script in w$$anonymous$$ch server are created and client are connect.
screen 1 two button Client (when clicked client is connected and clienrside screen is loaded) server (when clicked server is started and serverside screen is loaded)

clientside screen three button play (when clicked game is started on server side) left (when clicked car go towards left) right (when clicked car go towards right)

serverside 1 button play (to play from serverside manually )

now when game is started and clicked on play from client side game started on server side but again both server and client and on unity but what i want is the server of unity and 1 client of android app and i can control my game with is

UiManager Script using UnityEngine; using System.Collections;

public class UiManager : MonoBehaviour {

 // Use t$$anonymous$$s for initialization
 public GameObject car;
 public CarController moveCar;
 public NetworkView nView;
 string level1;
  
 void Start () {
     nView = GetComponent<NetworkView>();
     
 }

   


 // Update is called once per frame
 void Update () {
     ClientLeft();
    // networkView.RPC;
 }
     

    public void Pause()
 {
     if(Time.timeScale == 1)
     {
         Time.timeScale = 0;
     }
     else if(Time.timeScale == 0)
     {
         Time.timeScale = 1;
     }

 }

 string ip = "127.0.0.1" ;

 int portno = 25001;

 public void Server()
 {
    
         Network.InitializeServer(10, portno); 

         if (Network.peerType == NetworkPeerType.Server)
         {
             Application.LoadLevel("Menu");
         }
        
         
     }
 
   
 


 public void Client()
 {
         Network.Connect(ip, portno);
     if(Network.peerType == NetworkPeerType.Client)
     {
         Application.LoadLevel("clientSide");
     }
 
 }
 void OnConnectedToServer()
 {
     Application.LoadLevel("clientSide");
 }


 public void ClientPaly()
 {
     if (Network.peerType == NetworkPeerType.Client)
     {
         nView.RPC("Play", RPCMode.Server);
     }
 }

 public void ClientLeft()
 {
     if (Network.peerType == NetworkPeerType.Client)
     {

         // nView.RPC("moveLeft", RPCMode.Server);
         moveCar.moveLeft();
     }
 }

 public void ClientRight()
 {
     if (Network.peerType == NetworkPeerType.Client)
     {
         nView.RPC("moveRight", RPCMode.Server);
         
     }
 }

 [RPC]
 public void Play()
 {
     Application.LoadLevel("Level1");

 }

}

my project is of 55 mb what's why i can;t upload it here

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Cannot get objects to appear on client screen using new network system on Android wifi 0 Answers

Problem with connecting to AWS EC2 Server ... 0 Answers

Unity Multiplayer Android Game 0 Answers

Unity Network make Server and Connect 0 Answers

[UNET] Handle Client Disconnection 1 Answer


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