So, I’ve made a sword and made a script like this one :
#pragma strict
var TheDammage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var TheSword : Transform;
function Update ()
{
if (Input.GetButtonDown(“Fire1”))
{
//Attack animation
TheSword.animation.Play(“attack”);
//Attack function
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage(“ApplyDammage”, TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
if (TheSword.animation.isPlaying == false)
{
TheSword.animation.CrossFade(“idle”);
}
if (Input.GetKey (KeyCode.LeftShift))
{
TheSword.animation.CrossFade(“sprint”);
}
if (Input.GetKeyUp(KeyCode.LeftShift))
{
TheSword.animation.CrossFade(“idle”);
}
}
Now, the sword works correctly, all the animations load when needed… but I want to change the animations, and I can’t ! In the scene menu, the sword is around god-knows-where (completely random place, UNDER all my scenery etc) and when I drag it back to where I want it to be… it disappears.