Hey there!, so, I am making a game like space invaders, but, 1 player can only move the ship, and the other one can only fire!, only problem is right now, is that the level I have is randomly generated, so that means, on player 1 screen he is dodging ships, on player 2 screen he is flying into ships, player 2 dies but not player 1,
Here is some snipets of code I have:
// Player 1 controls gun only
(NetworkManager.playerType == 0)
{
if (Input.GetButtonDown ("Jump"))
{
Instantiate(mainBullet, transform.position + new Vector3(0f, 0f, 0.5f), transform.rotation);
}
//Player 2 controls movement only
if(NetworkManager.playerType == 1)
{
verticalSpeed = Mathf.SmoothDamp (verticalSpeed, verticalTopSpeed * Input.GetAxis ("Vertical"), ref verticalSpeedV, verticalSpeedChange);
horizontalSpeed = Mathf.SmoothDamp (horizontalSpeed, horizontalTopSpeed * Input.GetAxis ("Horizontal"), ref horizontalSpeedV, horizontalSpeedChange);
transform.position = new Vector3 (Mathf.Clamp (transform.position.x + horizontalSpeed * Time.deltaTime, -maxHorizontalPos, maxHorizontalPos),
transform.position.y,
Mathf.Clamp (transform.position.z + verticalSpeed * Time.deltaTime, minVerticalPos, maxVerticalPos));
}
// The gui in my Network Manager file
void OnGUI()
{
if(!Network.isClient !Network.isServer)
{ if(GUI.Button(new Rect(300, 600, 180, 20), "Start Server"))
{
Debug.Log ("Starting server");
startServer ();
playerType = 1;
}
if(GUI.Button(new Rect(300, 640, 180, 20), "Refresh Hosts"))
{
Debug.Log ("Refreshing");
refreshHostList();
}
if(GUI.Button(new Rect(700, 600, 180, 20), "Solo"))
{
Debug.Log ("Riding solo");
NetworkManager.playerType = 0;
Application.LoadLevel("Main");
}
if(hostData != null)
{
for (int i = 0; i < hostData.Length; i++)
{
if(GUI.Button(new Rect(300, 730, 200, 30), hostData[i].gameName))
{
Network.Connect(hostData[i]);
playerType = 0;
Application.LoadLevel("Main");
}
}
}
}
}
I don’t know what else I would need to show, the level has the same background and stuff, only the enemies coming down the screen are random, here is a youtube video:
(Ignore the fact that the server ship got hit more then 3 times and didnt die, it was for testing purposes)
I think setting up the lives and score would be easy?, but I don’t know about the level, is it possible? to share a random level?
I really dont want to set waves that aren’t random
Also, this is written in C# just in case anyone is wondering