Question by
Inverrtted · Jun 01, 2017 at 08:13 AM ·
scripting problemscript.damagescript errorget
Error CS0177 - "GameManager does not contain a definition for 'GetPlayer' PLEASE HELP!
I have been presented with this in my PlayerShoot Code. Error CS0117: 'GameManager' does not contain a definition for 'GetPlayer' (CS0117) (Assembly-CSharp), Here is my code, thanks for looking :) using UnityEngine.Networking; using UnityEngine;
public class PlayerShoot : NetworkBehaviour {
private const string PLAYER_TAG = "Player";
public PlayerWeapon weapon;
[SerializeField]
private Camera cam;
[SerializeField]
private LayerMask mask;
void Start ()
{
if (cam == null) {
Debug.LogError
("PlayerShoot: No camera referenced!");
this.enabled = false;
}
}
void Update ()
{
if (Input.GetButtonDown ("Fire1")) {
Shoot ();
}
}
[Client]
void Shoot ()
{
RaycastHit _hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, weapon.range, mask))
{
if (_hit.collider.tag == PLAYER_TAG) {
CmdPlayerShot (_hit.collider.name, weapon.damage);
}
Debug.Log ("Player " + GetComponent<NetworkIdentity> ().netId + " hit " + _hit.collider.name);
}
}
[Command]
void CmdPlayerShot (string _playerID, int _damage)
{
Debug.Log (_playerID + " has been shot.");
Player _player = GameManager.GetPlayer (_playerID);
_player.TakeDamage (_damage);
}
}
Comment