- Home /
I have been watching his tutorial but nothing happens
I downloaded the assets folder that him putted on his video, but when i add the script to the empty object, the enemy don´t lose health.THERE IS FIRTS THE MELEE SYSTEM SCRIPT AND SECOND THE ENEMY HEALTH SCRIPT, PLEASE TELLME WAHT I DID WRONG, HERE IS THE TUTORIAL LINK: http://www.youtube.com/watch?v=HzTceINFowY&lc=pxBg1RDOkZT48VdBVNLOTZ7EnYB6MeCUuMH_-hybGCU
//IMPORTANT NOTE: This script was updated last in tutorial number 6. If you haven't watched it yet, go do it before messaging me with errors :)
#pragma strict
var TheDammage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var TheSystem : Transform;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
//Attack animation - IF YOU ARE GETTING ERRORS BECAUSE YOU HAVENT MADE AN ANIMATION AND ATTACHED IT, DELETE THE FOLOWING LINE.
animation.Play("Attack");
}
// if (TheMace.animation.isPlaying == false)
// {
// TheMace.animation.CrossFade("Idle");
// }
//
// if (Input.GetKey (KeyCode.LeftShift))
// {
// TheMace.animation.CrossFade("Sprint");
// }
//
// if (Input.GetKeyUp(KeyCode.LeftShift))
// {
// TheMace.animation.CrossFade("Idle");
// }
}
function AttackDammage ()
{
//Attack function
var hit : RaycastHit;
if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
Please provide more information. What is not working? What is happening that shouldn't be happening? What have you tried to amend this?
Please refrain from POSTING IN ALL CAPS because it's just plain rude, thank ;)
It may be helpful to not spam caps, and also call attackdammage();
if (Input.GetButtonDown("Fire1"))
{
//Attack animation - IF YOU ARE GETTING ERRORS BECAUSE YOU HAVENT $$anonymous$$ADE AN ANI$$anonymous$$ATION AND ATTACHED IT, $$anonymous$$ETE THE FOLOWING LIN$$anonymous$$
animation.Play("Attack");
AttackDammage ();
}
Your answer
Follow this Question
Related Questions
Animation for weapon plays on game start instead of when i attack 2 Answers
Trying to get enemy to aim at the player and shoot at it 2 Answers
InvalidCastException: Cannot cast from source type to destination type. ??? 2 Answers
Script error: OnTriggerEnter 1 Answer
NullReferenceException: Object reference not set to an instance of an object 1 Answer