Question by
importguru88 · Jun 02, 2016 at 05:44 PM ·
scripting problemdamagescript errorapply
error CS0103: The name `yourCharacter' does not exist in the current context
I trying to apply damage to the health bar . I got one error. Here is my script :
using UnityEngine;
using System.Collections;
using Opsive.ThirdPersonController.Wrappers;
public class Damage : MonoBehaviour {
int health;
Healthbar healthbar;
void Start () {
yourCharacter.GetComponent<Health>.CurrentHealth.
healthbar = FindObjectOfType<Healthbar>();
if (healthbar == null)
{
Debug.LogError("I am hit!");
}
}
void Update () {
}
}
Comment
Answer by Static-Dynamo · Jun 02, 2016 at 11:10 PM
What is yourCharacter? This line-
yourCharacter.GetComponent<Health>.CurrentHealth.
healthbar = FindObjectOfType<Healthbar>();
does not make any sense because the script has no idea what yourCharacter is. You have not declared it anywhere in this script.
Your answer
Follow this Question
Related Questions
Bullet Intersect Script Problem 1 Answer
Error CS0177 - "GameManager does not contain a definition for 'GetPlayer' PLEASE HELP! 0 Answers
Singleton Problem 0 Answers
Help with Script 0 Answers
Interesting Script Problem 1 Answer