so I made a combat script that has both the enemy’s and the main character and his party. with also the battle layout
but its giving me errors tell me what I am doing wrong here.
var Jake : CharacterAtt;
var block : Vector2;
var combatPosition : Vector3[] = new Vector3[6];
enum CombatPos
{
Playerleft = 0,
Playercenter = 1,
Playerright = 2,
Enemyleft = 3,
Enemycenter = 4,
Enemyright = 5
}
function Start () {
for(var i : int = 0;i < 6;i++)
{
if(i< 3)combatPosition[i] = Vector3(transform.position.x +((i-((i<3)?1))*block.x),0,transform.position.z-(((i<3)?1)*block.y);
else combatPosition[i] = Vector3(transform.position.x +((i-((i<3)?4)*block.x)),0,transform.position.z+(((i<3)?1)*block.y));
}
Jake = new CharacterAtt(Player.Jake,"Jake",20,21,19,18,22,22,23,1000);
Jake.Addweapon(new Weapon("knife",1,10,false,Element.physical,50,Player.Jake));
}
here are the errors: expecting ), found ‘block’., ‘;’ expected. Insert a semicolon at the end., expecting ), found ‘*’. and the rest are just like these errors so can some one tell me what I should do for my combatgrid? the max count is
six so three tiles for the player and three tiles for enemies. here is my new code:
var Jake : CharacterAtt;
var block : Vector2;
var combatPosition : Vector3[] = new Vector3[6];
enum CombatPos
{
Playerleft = 0,
Playercenter = 1,
Playerright = 2,
Enemyleft = 3,
Enemycenter = 4,
Enemyright = 5
}
function Start ()
{
for(var i : int = 0;i < 6;i++)
{
if(i< 3)combatPosition[i] = Vector3(transform.position.x +((i-((i<3)?1))*block.x),0,transform.position.z-(((i<3)?1)*block.y));
else combatPosition[i] = Vector3(transform.position.x +((i-((i<3)?4)*block.x)),0,transform.position.z+(((i<3)?1)*block.y));
}
Jake = new CharacterAtt(Player.Jake,"Jake",20,21,19,18,22,22,23,1000);
Jake.Addweapon(new Weapon("knife",1,10,false,Element.physical,50,Player.Jake));
}
I have my combat scene all hooked up I and is working when I hit play. Now I am on my command menu and have my basic
attack animation ready and he can give damage to the enemy but it looks like a ranged attack when it should be melee attack.
it also gives me this error when I hit play:
The variable Knife of ‘JakeAnimateC’ has not been assigned.
You probably need to assign the Knife variable of the JakeAnimateC script in the inspector.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:44)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:53)
JakeAnimateC+$AttackTarget$34+$.MoveNext () (at Assets/Scripts/movement/JakeAnimateC.js:37)
so here is the script too
#pragma strict
var Knife : Transform;
var attackcomplet:boolean = false;
var Knifepoint;
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 code dose work and It animates my Jake character properly
ok I look over my code and I forgot to add Vector3 to Knife but it still shows the same error. Oh and Ignore the very top question
and here is the new code:
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;
}
}
so Ignore this post I just answered my own Question