- Home /
Question by
DarkDamien · Mar 20, 2014 at 06:15 AM ·
inputtargetattackscipting
I have two errors can someone help me out
I'm getting 2 errors on this code. I wanted to see if anyone could help me fix them. The two errors I'm receiving are the following:
error 1:Assets/Scripts/playerAttack.cs(28,9): error CS1525: Unexpected symbol `}'
error 2:Assets/Scripts/playerAttack.cs(29,1): error CS8025: Parsing error
Thanks for any aid you guys can provided.
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))
{
Attack();
}
}
private void Attack()
{
enemyHealth eh = (enemyHealth)target.GetComponent("enemyHealth");
eh.AddjustCurrentHealth(-10)
}
}
Comment
Best Answer
Answer by Destran · Mar 20, 2014 at 06:23 AM
Try this:
using UnityEngine;
using System.Collections;
public class playerAttack : MonoBehaviour
{
public GameObject target;
void Update ()
{
if(Input.GetKeyUp(KeyCode.F))
{
Attack();
}
}
private void Attack()
{
enemyHealth eh = (enemyHealth)target.GetComponent("enemyHealth");
eh.AddjustCurrentHealth(-10);
}
}
You missed a semicolon on line 28
Your answer
Follow this Question
Related Questions
Quick Attack/Heavy Attack on Same Input 1 Answer
Multiple Animations, Please Help 1 Answer
Is there a way to do different things depending on whether the button is being held or tapped? 2 Answers
How to Attack using Animation and Input 0 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers