Skip to content
Snippets Groups Projects
Commit f04f90a3 authored by jan's avatar jan
Browse files

Player is now first person, new controls

parent 259b4a75
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
fileFormatVersion: 2
guid: d5924e98ca515504e8b0fe3d1411b4e8
timeCreated: 1456162605
timeCreated: 1456763149
licenseType: Free
NativeFormatImporter:
userData:
......
File deleted
fileFormatVersion: 2
guid: bfda530292cecdb418240f20ef4ecee6
timeCreated: 1455742202
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
......@@ -13,11 +13,7 @@ public class CustomNetworkManager : NetworkManager
{
NetworkManager.singleton.networkPort = port;
NetworkManager.singleton.StartHost();
Debug.Log("Started Host");
}
else
Debug.Log("Failed to host!");
}
public void JoinGame()
......@@ -27,11 +23,7 @@ public class CustomNetworkManager : NetworkManager
NetworkManager.singleton.networkAddress = GameObject.Find("IPAdressTextBox").transform.FindChild("Text").GetComponent<Text>().text;
NetworkManager.singleton.networkPort = port;
NetworkManager.singleton.StartClient();
Debug.Log("Joined: " + NetworkManager.singleton.networkAddress);
}
else
Debug.Log("Failed to join!");
}
public void OnLevelWasLoaded(int level)
......@@ -49,7 +41,5 @@ public class CustomNetworkManager : NetworkManager
GameObject.Find("DisconnectButton").GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find("DisconnectButton").GetComponent<Button>().onClick.AddListener(NetworkManager.singleton.StopHost);
}
Debug.Log("Level was loaded");
}
}
\ No newline at end of file
......@@ -5,6 +5,9 @@ using System.Collections;
public class Movement : NetworkBehaviour
{
public GameObject bulletPrefab;
public float mouseSensitivity = 2;
private float rotationX, rotationY;
public override void OnStartLocalPlayer()
{
......@@ -14,13 +17,35 @@ public class Movement : NetworkBehaviour
GetComponentInChildren<AudioListener>().enabled = true;
}
void Update()
public void Start()
{
transform.Translate(Vector3.up);
}
public void Update()
{
if (!isLocalPlayer)
return;
transform.Translate(Input.GetAxis("Horizontal") * 0.1f, 0, Input.GetAxis("Vertical") * 0.1f);
//Movement
Vector3 direction = Vector3.zero;
direction += Vector3.Cross(Vector3.up, -transform.right) * Input.GetAxis("Vertical") * 0.1f;
direction += transform.right * Input.GetAxis("Horizontal") * 0.1f;
transform.position += direction;
//Rotation
rotationX += Input.GetAxis("Mouse X") * mouseSensitivity;
transform.rotation = Quaternion.AngleAxis(rotationX, Vector3.up);
rotationY += Input.GetAxis("Mouse Y") * -mouseSensitivity;
rotationY = Mathf.Clamp(rotationY, -80, 80);
transform.rotation *= Quaternion.AngleAxis(rotationY, Vector3.right);
//Shooting
if (Input.GetKeyDown(KeyCode.Space))
CmdFire();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment