- Home /
Question by
Deadman9527 · May 17, 2015 at 07:57 PM ·
animationjavascriptunity5
I can't edit my animation or play my other animation
I have done everything possible for this, however, for some reason I can't edit my animation or even open it for that matter in the Unity engine. Could it be because I edit the name on the animation? Also, while were at it for some reason I cannot use my Sword Mechanic that I was able to use before. To help trouble shoot the problem I'll show vids, and pics so I can show you what the problem here is.
My Code for the character:
//if statements should be highly recommended to use when a statement out of an if statement is preformed.
var Character : Rigidbody;
var CharacterHealth : int = 100;
var timer : int = 0;
var JumpLimit : int = 2;
var NumberofSwings : int = 0;
var TimesSwungSword : int = 3;
var OnlyOneTime : int = 1;
var NumberofJumps : int = 0;
var CanYouJump : boolean = false;
var cam : Quaternion;
var WalkingAnimation : Animation;
var SwingingSword : Animation;
var Blocking : Animation;
var SwordMegaSlash : Animation;
var CharacterSound : AudioSource;
var CharacterAttack : AudioSource;
var CharacterBlock : AudioSource;
var CharacterBlockSoundEffect : AudioSource;
function Start()
{
cam = transform.rotation;
}
function Update()
{
//The Control Panel for All the Mechanics down Below
var Walk = Vector3(10, 0, 0);
var JumpHeight = Vector3(0,20,0);
var WalkLeft = Vector3(-10, 0, 0);
var JumpMechanic = Input.GetKeyDown("space");
var WalkRightMechanic = Input.GetKey("d");
var WalkLeftMechanic = Input.GetKey("a");
var SwordMechanic = Input.GetKeyDown("e");
var BlockMechanic = Input.GetKeyDown("b");
NumberofJumps = JumpLimit;
NumberofSwings = TimesSwungSword;
//Where the action is taken place
if(WalkRightMechanic)
{
Character.velocity = Walk;
WalkingAnimation.Play();
}
if(WalkLeftMechanic)
{
Character.velocity = WalkLeft;
WalkingAnimation.Play();
}
if(JumpMechanic&&CanYouJump == false&&NumberofJumps == JumpLimit)
{
CanYouJump = true;
Character.velocity = JumpHeight;
CharacterSound.Play();
}
if(SwordMechanic)
{
SwingingSword.CrossFade("SwingingSword");
CharacterAttack.Play();
}
if(SwordMechanic&&NumberofSwings == TimesSwungSword)
{
SuperMegaSword.CrossFade("SuperMegaSword");
}
if(BlockMechanic)
{
Blocking.CrossFade("Blocking");
CharacterBlockSoundEffect.PlayDelayed(3);
CharacterBlock.PlayDelayed(3);
CharacterBlock.volume = 4;
CharacterBlockSoundEffect.volume = 3;
CharacterBlockSoundEffect.Play();
CharacterBlock.Play();
}
}
function OnGUI()
{
var ElapsedTime = ++timer*Time.deltaTime*1
GUI.Box(new Rect(100, 100, 100, 100) ElapsedTime);
}
function OnCollisionStay()
{
CanYouJump = false;
}
function LateUpdate()
{
transform.rotation = cam;
}
This is the sword mechanic I'm having trouble with:
if(SwordMechanic)
{
SwingingSword.CrossFade("SwingingSword");
CharacterAttack.Play();
}
if(SwordMechanic&&NumberofSwings == TimesSwungSword)
{
SuperMegaSword.CrossFade("SuperMegaSword");
}
Video to my problem: https://www.dropbox.com/s/2x2q43ux2mlkv3t/Untitled.avi?dl=0
It could also be the enemy script prohibiting the attack
var EnemyHealth : int = 100;
var TragetTracker : Collider;
var Player : GameObject;
var EnemyObject : GameObject;
var PlayerSword : Rigidbody;
var EnemyWalkingAnimation : Animation;
var EightyFightAnimation : Animation;
var SixtyFightAnimation : Animation;
var FourtyFightAnimation : Animation;
var TwentyFightAnimation : Animation;
var ZeroFightAnimation : Animation;
//numbers are not allowed as variable names
//Got to be precise for the Animations name other wise it won't work
function OnCollisionEnter(PlayerSword)
{
if(PlayerSword.contacts)
{
EnemyWalkingAnimation.Play();
EnemyHealth += -5;
}
}
function OnTriggerEnter(info : Collider)
{
if(info.tag == "Player")
{
EnemyObject = GameObject.Find("Player");
}
switch(EnemyHealth)
{
//I forgot how switches work, my apologies XD
//as I remember switches and cases do not require {}. or Cases don't switches do.
case(EnemyHealth <= 80):
Debug.Log("I got hit");
break;
case(EnemyHealth<=60):
SixtyFightAnimation.CrossFade("SixtyFightAnimation");
break;
case(EnemyHealth<=40):
FourtyFightAnimation.CrossFade("FourtyFightAnimation");
break;
case(EnemyHealth<=20):
TwentyFightAnimation.CrossFade("TwentyFightAnimation");
break;
case(EnemyHealth<=0):
ZeroFightAnimation.CrossFade("ZeroFightAnimation");
break;
default:
EnemyWalkingAnimation.Play();
break;
}
}
screenshot-2015-05-08-103831.png
(146.5 kB)
screenshot-2015-05-08-103829.png
(140.8 kB)
Comment