The problem is not the script,the script works fine the problem is that in unity 4.0 the function
animation.Play(“walking”)
isnt working i dont know what to do for that so if someone knows plz help me because have stuck at this problem for almost 3 months and i can do nothing!!
here is the script if anyone knows hot to make the animation to play in unity 4.0 plz help me
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;
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.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);
}