Hi all,
I’m calling a Draw/SheatSword() function with a event function via Mecanim.
It works, but I have the problem that the rotation is wrong when the sword is sheated. The localRotation vaules are not the same I coded.
Besides this everytime the Draw/SheatSword() function is called I am getting this error message:
UnassignedReferenceException: The variable weapon of ‘NewPlayerControl’ has not been assigned.
You probably need to assign the weapon variable of the NewPlayerControl script in the inspector.
NewPlayerControl.DrawSword () (at Assets/Scripts/Entity/Player/NewPlayerControl.js:410)
I assume the rotation can’t be assigned because he has no weapon variable when the function is called an generates an error.
This is my code, I can’t find an error.
var weapon : Transform;
var myHandBone : Transform;
var myHipBone : Transform;
function DrawSword() {
weapon.parent = myHandBone;
weapon.localPosition.x = -0.1647566;
weapon.localPosition.y = 0.05176726;
weapon.localPosition.z = 0.001803763;
weapon.localRotation.x = 7.513212e-05;
weapon.localRotation.y = 249.9859;
weapon.localRotation.z = 270.0002;
}
function SheatSword() {
weapon.parent = myHipBone;
weapon.localPosition.x = -0.05071573;
weapon.localPosition.y = -0.2928329;
weapon.localPosition.z = 0.112793;
weapon.localRotation.x = 34.14093;
weapon.localRotation.y = 241.5118;
weapon.localRotation.z = 259.439;
}
I hope someone could help me.
Best regards,
0tacun