Unity3D First Person Android Multiplayer Game

0 votes
Hello
Once it comes to Unity3D, Android, first person
I'm unfortunately not a top programmer and wanted to ask whether someone screene the demo of warp 2 to write, so the I can the script just as at warp 1 to the objects can move and is ready (after I've changed confi) also I find it stupid the control function in the warp script since it always makes my spawn function defective.

Thanks in advance :)

 

asked Mar 23, 2014 in AppWarpS2 by dobby5 (16 points)

1 Answer

0 votes
Which demo is giving you the errors?

What is the error you are getting?

Is this error only in Android?
answered Mar 24, 2014 by dhruvc (1,099 points)
Also, please clarify what you mean by warp 1 and warp 2?
Hi I want the first person as well as the remote function from the warp 2 demo script've unfortunately I do not know how that goes.

can you help me ?

info: I have a warp 2 Server
Have you followed the tutorial on our site?
http://appwarps2.shephertz.com/dev-center/samples/viking-demo/
The scripts add a new viking when the onChatReceived event is called. We check the sender and based on that spawn a new Viking. If the sender name is "robot", we move the robot accordingly.
yes I have seen the tutorial but I want to have removed no spawn script as well as the third person script because my game is a first person game.
We also have a first person sample. Its available for AppWarp cloud. However you can take a look at that and modify it to work against the on-premise server as well. Here is a link to that. You can get the source code of the sample from

https://github.com/shephertz/AppWarpUnity/tree/master/Sample

This page contains a walk through as well. (The beginning of the video is a bit outdated)
 
http://appwarp.shephertz.com/game-development-center/unity3d-game-developers-home/
can you update

    public static string apiKey = "<api key>";
    public static string secretKey = "<secret key>";
    public static string roomid = "<room id>";

to

    public static string apiKey = "<api key>";
    public static string ipadress = "<IP>";
    public static string roomid = "<room id>";

?
Yes. So replace the AppWarpUnity.dll with AppWarpS2Unity.dll.

And then put in the values of api_key that you get when you create an application from the AppWarp S2 Admin dashboard.

Instead of secret key - you put in the address of the S2 server.

And the room id is what you create from AppWarp S2 Admin dashboard.

In Connect, pass in an empty string as the second argument for eg:

WarpClient.getInstance()->Connect("dobby", "");
Is this right ? For me it is not where is my mistake?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

using com.shephertz.app42.gaming.multiplayer.client;
using com.shephertz.app42.gaming.multiplayer.client.events;
using com.shephertz.app42.gaming.multiplayer.client.listener;
using com.shephertz.app42.gaming.multiplayer.client.command;
using com.shephertz.app42.gaming.multiplayer.client.message;
using com.shephertz.app42.gaming.multiplayer.client.transformer;

//using UnityEditor;

using AssemblyCSharp;

public class appwarp : MonoBehaviour {

    //please update with values you get after signing up
    public static string apiKey = "/";
    public static string secretKey = "/";
    public static string roomid = "/";
    public static string username;
    Listener listen = new Listener();
    public static Vector3 newPos = new Vector3(0,0,0);
   
    void Start () {
        WarpClient.initialize(apiKey,secretKey);
        WarpClient.GetInstance().AddConnectionRequestListener(listen);
        WarpClient.GetInstance().AddChatRequestListener(listen);
        WarpClient.GetInstance().AddLobbyRequestListener(listen);
        WarpClient.GetInstance().AddNotificationListener(listen);
        WarpClient.GetInstance().AddRoomRequestListener(listen);
        WarpClient.GetInstance().AddUpdateRequestListener(listen);
        WarpClient.GetInstance().AddZoneRequestListener(listen);
       
        // join with a unique name (current time stamp)
        username = System.DateTime.UtcNow.Ticks.ToString();
        WarpClient.GetInstance().Connect("username", "");
       
        //EditorApplication.playmodeStateChanged += OnEditorStateChanged;
        addPlayer();
    }
   
    public float interval = 0.1f;
    float timer = 0;

   
    public static GameObject obj;
   
    public static void addPlayer()
    {
        obj = GameObject.CreatePrimitive(PrimitiveType.Capsule);
        obj.transform.position = new Vector3(732f,1.5f,500f);
    }
   
    public static void movePlayer(float x, float y, float z)
    {
        newPos = new Vector3(x,y,z);
    }
   
    void Update () {
        timer -= Time.deltaTime;
        if(timer < 0)
        {
            string json = "{\"x\":\""+transform.position.x+"\",\"y\":\""+transform.position.y+"\",\"z\":\""+transform.position.z+"\"}";
           
            listen.sendMsg(json);
           
            timer = interval;
        }
       
        if (Input.GetKeyDown(KeyCode.Escape)) {
            Application.Quit();
        }
        WarpClient.GetInstance().Update();
        obj.transform.position = Vector3.Lerp(obj.transform.position, newPos, Time.deltaTime);
    }
   
    void OnGUI()
    {
        GUI.contentColor = Color.black;
        GUI.Label(new Rect(10,10,500,200), listen.getDebug());
    }
   
    /*void OnEditorStateChanged()
    {
        if(EditorApplication.isPlaying == false)
        {
            WarpClient.GetInstance().Disconnect();
        }
    }*/
   
    void OnApplicationQuit()
    {
        WarpClient.GetInstance().Disconnect();
    }
   
}
What is the error you are getting? Does it compile and build? Does the client connect to your AppWarp S2 server?
I do not see the other players. I may have to the server nor an extra set I now have the server datein taken from the viking demo. Since it is an android game ego've already with the mobile version just as with the normal dll version of warp2unity tried.
Do you see onConnectDone 0?

Does the desktop version work?

For android you need to use AppWarpS2UnityMobile.dll and the Plugins folder in Assets.
I dont have onConnectDone 0
with the desktop version i dont see the other player
with the mobile version I have to test that again any error was there but do not know what more.
By the first player everything is ok
by the second player i have onConnectDone 1
onConnectDone 1 means that the appKey you've passed in WarpClient.initialize() is wrong or a user with the same name is already connected.
I think that the same name is already being used as the first client you connected, and the second is not what am I supposed to do against.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...