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 /
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 which 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 thing will work on your computer/unity(server) which is control by your android app(client). now i have just implemented this 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 something on which i can work and can get started i am using UiManager script in which 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 this 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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to connect to a match by a string 0 Answers

UNet NetworkServer max connections 4 Answers

Best way to create a UDP network for Android 0 Answers

How to do communication between apps. ( Android ) 2 Answers

Some questions about unity app's tcp connection state in Android sleep mode 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