I’m working on an mmo and the Player Attack script needs all compiler errors fixed, can someone help me with this?
Script is:
using UnityEngine;
using System.Collections;
public class PlayerAttack : MonoBehaviour {
public GameObject target;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.F)) {
PlayerAttack();
}
}
void Attack() {
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.AddjustCurrentHealth(-10);
}
}
MMO eh, good luck with that xD
looks like good ol’ petey’s code, are you doing the hack’n’slash tutorial by chance? If so, watch the next video- I’m pretty sure he tells you how to fix the error. Also, whenever you run across specific problems doing his tutorials, try posting them on the BurgZergArcade forums- since everybody over there is doing the tutorials also, you’ll get better responses.
And lastly- “Error CS0119” is pretty useless information out of context. All that tells us is that you tried to access a parameter as a method, or some similar misuse of a type. Since we don’t have all of your code, that doesn’t help us. When you get an error- copy the whole text, not just the error number. and if possible, make note of which line of code it’s pointing to.