so I have this script it work fine but but when the player attacks the animation plays but he looks like he is slashing air and the knife
he has is on him but it dose not move with him he is also in the same place too when the attack animation plays. He dose not
move foward to the target? here is my code:
#pragma strict
var Knife:Transform;
var attackcomplet:boolean = false;
var Knifepoint:Vector3;
var myCombatC:CombatC;
function Start()
{
for(var child: Object in transform)
{
if((child as Transform).name == "knifepoint")Knifepoint = (child as Transform).position;
}
}
function AttackTarget(myId:BaseStats,targetId:BaseStats)
{
var initialRotation:Quaternion = transform.rotation;
var targetRotation:Quaternion = Quaternion.LookRotation(targetId.myInstance.position - transform.position);
var delta : float = 0.0;
while(delta<1.0)
{
delta += Time.deltaTime;
transform.rotation=Quaternion.Slerp(initialRotation,targetRotation,delta);
transform.eulerAngles.x=0.0;
transform.eulerAngles.z=0.0;
yield;
}
var thisknife:Transform = Instantiate(Knife,Knifepoint,transform.rotation);
transform.Translate(transform.forward*10*Time.deltaTime);
animation.Play("attack");
yield;
while(!attackcomplet)yield;
attackcomplet = false;
yield Addeffect((myId as CharacterAtt).Attack(targetId as NPCAtt),targetId.myInstance);
delta = 0.0;
while(delta<1.0)
{
delta += Time.deltaTime;
transform.rotation = Quaternion.Slerp(targetRotation,initialRotation,delta);
transform.eulerAngles.x =0.0;
transform.eulerAngles.z=0.0;
yield;
}
}
function Addeffect(attackoutput:Attackoutput,Target:Transform)
{
switch(attackoutput.result)
{
case Attackresult.Miss:
Target.position.x +=1.0;
yield WaitForSeconds(1.0);
Target.position.x -=1.0;
break;
}
}
this script is in java and it works fine with no errors its just looks like it is a ranged attack when it should be melee?
this is for anyone and here if this helps Ignore the top post
here is the full script for my attacking player its the same as above but it has the miss,hit, and critical:
var Knife:Transform;
var attackcomplet:boolean = false;
var Knifepoint:Vector3;
var myCombatC:CombatC;
var displayPosition:Vector3;
function Start()
{
GameObject.FindGameObjectWithTag("Weapon");
myCombatC = gameObject.Find("combatgrid").GetComponent(CombatC);
}
function AttackTarget(myId:BaseStats,targetId:BaseStats)
{
var initialRotation:Quaternion = transform.rotation;
var targetRotation:Quaternion = Quaternion.LookRotation(targetId.myInstance.position - transform.position);
var delta : float = 0.0;
while(delta<1.0)
{
delta += Time.deltaTime;
transform.rotation=Quaternion.Slerp(initialRotation,targetRotation,delta);
transform.eulerAngles.x=0.0;
transform.eulerAngles.z=0.0;
yield;
}
var thisknife:Transform = Instantiate(Knife,Knifepoint,transform.rotation);
animation.Play("attack");
yield;
while(!attackcomplet)yield;
attackcomplet = false;
yield Addeffect((myId as CharacterAtt).Attack(targetId as NPCAtt),targetId.myInstance);
delta = 0.0;
while(delta<1.0)
{
delta += Time.deltaTime;
transform.rotation = Quaternion.Slerp(targetRotation,initialRotation,delta);
transform.eulerAngles.x =0.0;
transform.eulerAngles.z=0.0;
yield;
}
}
function Addeffect(attackoutput:Attackoutput,Target:Transform)
{
switch(attackoutput.result)
{
case Attackresult.Miss:
Target.position.x +=1.0;
myCombatC.DisPlayText(displayPosition,"Miss");
displayPosition =Vector3.zero;
yield WaitForSeconds(1.0);
Target.position.x -=1.0;
break;
case Attackresult.Hit:
myCombatC.DisPlayText(displayPosition,attackoutput.damage.ToString());
yield WaitForSeconds(1.0);
displayPosition =Vector3.zero;
break;
case Attackresult.Critical:
myCombatC.DisPlayText(displayPosition,attackoutput.damage.ToString());
yield WaitForSeconds(1.0);
displayPosition =Vector3.zero;
break;
}
}
this is gose on my Jake character called battle Jake. if someone can help me out here this script is the animation
script for the command menu in the battle scenes.and this is for the main character. I just have right now is the
basic attack command.