- Home /
Question by
SavvaMadar · Oct 13, 2012 at 07:20 AM ·
missing
NEED HELP CODING, CANT FIND MISTAKE
var Clips : int = 20;
var Range : float = 900;
var Force : float = 900;
var BulletsInClip : int = 27;
var RelodeTime : float = 4;
var BulletsLeft : int = 0;
var ShootTimer : float = 0;
var ShootCooler : float =0.9;
var RelodingAudio : AudioClip;
var ShootingAudio : AudioClip;
var ShootingAnimation : Animation;
var ReloadingAnimation : Animation;
var ReloadingString : String;
var ShootingString : String;
var BodyImpact : Transform;
function Start ()
{
BulletsLeft = BulletsInClip;
}
function Update ()
{
if (ShootTimer > 0)
{
ShootTimer -= Time.deltaTime;
if(ShootTimer < 0)
{
ShootTimer = 0;
}
}
if (Input.GetMouseButton(0)&& BulletsLeft > 0)
{
if(BulletsLeft == 0)
{
Relode();
}
if (ShootTimer == 0)
{
Shooter();
ShootTimer = ShootCooler;
}
}
if (Input.GetKeyDown(KeyCode.R))
{
Relode();
}
}
function Shooter ()
{
ShootingAnimation.Play(ShootingString);
var Hit : RaycastHit;
var DirectionRay = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, DirectionRay,Hit,Range))
{
if(Hit.collider.tag == "Flesh" && Hit.collider.tag == "NPC")
{
Transform obj = Instantiate(BodyImpact,Hit.point,Quaternion.FromToRotation(Vector3.forward,Hit.normal)) as Transform;
obj.parent = Hit.transform;
obj.Translate(Vector3.up * 1.0f);
}
if (Hit.rigidbody)
{
Hit.rigidbody.AddForceAtPosition(DirectionRay * Force, Hit.point);
}
}
BulletsLeft --;
PlayShootAudio();
if(BulletsLeft < 0)
{
BullletsLeft =0;
}
if(BulletsLeft == 0)
{
Relode();
}
}
function Relode ()
{
PlayRelodeAudio();
ReloadingAnimation.Play(ReloadingString);
yield WaitForSeconds(RelodeTime);
if(Clips > 0)
{
BulletsLeft = BulletsInClip;
Clips--;
}
}
function PlayShootAudio ()
{
audio.PlayOneShot(ShootingAudio);
}
function PlayRelodeAudio ()
{
audio.PlayOneShot(RelodingAudio);
}
It says that I am missing a semi colon but I'm not experienced enough to find where it is...
Comment
Best Answer
Answer by MarkFinn · Oct 13, 2012 at 11:31 AM
I don't do JavaScript, but it seems to me that line 64 is using C# format, not Javascript?
Try replacing
Transform obj = Instantiate(BodyImpact,Hit.point,Quaternion.FromToRotation(Vector3.forward,Hit.normal)) as Transform;
with
var obj : Transform = Instantiate(BodyImpact,Hit.point,Quaternion.FromToRotation(Vector3.forward,Hit.normal)) as Transform;
(That certainly clears the error when I just throw it into a project. No idea if it'll actually work though).
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Why does certain sides of my building disapear at certain angles? 2 Answers
I'm Getting Weird Bugs Today 1 Answer
I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer
Having trouble with player.transform 1 Answer