So far so good, the Big Arm works in both directions now. But if i try the same with the small arm and the shovel, only one direction works like this, the other stucks in the end. No idea why.
Edit 1: Never mind, it resets on restart, since the animations from the FBX are read-only. So it doesn’t save the events in the animation window. I’ll try to use the Events in the FBX directly.
Edit 2: In the Animation Clip Event, same problem: Big Arm Works now, Small Arm and Shovel only to one site. But once they reached the highest point, they don’t reset like the Big Arm. I’ll look into the code again, maybe it’s a typo. But i don’t think so.
Edit 3: Seems i have no coding errors. It just doesn’t work. I try reimport the model. Maybe something weird happen with it.
Edit 4: I can’t find the Problem, even after reimporting it doesn’t work. Only BigArm works, Small Arm and Shovel don’t… or at least do the Up direction, but not down/ or maybe 1 frame down.
Time for some code?
//-------------------------------------------------BIGARM-----------------------------------------------------------------
if(Input.GetKey(KeyCode.E)&& !Input.GetKey(KeyCode.D)&&(!changeBigArmDirection || !nextBigArmIsUp))
{
changeBigArmDirection=false;
nextBigArmIsUp=true;
anim.SetFloat("BigArmSpeed",1f);
}
if(!Input.GetKey(KeyCode.E)&&Input.GetKey(KeyCode.D)&&(!changeBigArmDirection || nextBigArmIsUp))
{
changeBigArmDirection=false;
nextBigArmIsUp=false;
anim.SetFloat("BigArmSpeed",-1f);
}
else
{
//anim.SetFloat("BigArmSpeed",0);
}
//-------------------------------------------------------SMALLARM-------------------------------------------------------------
if(Input.GetKey(KeyCode.W)&& !Input.GetKey(KeyCode.S)&&(!changeSmallArmDirection || !nextSmallArmIsUp))
{
changeSmallArmDirection=false;
nextSmallArmIsUp=true;
anim.SetFloat("SmallArmSpeed",1f);
}
if(!Input.GetKey(KeyCode.W)&&Input.GetKey(KeyCode.S)&&(!changeSmallArmDirection || nextSmallArmIsUp))
{
changeSmallArmDirection=false;
nextSmallArmIsUp=false;
anim.SetFloat("SmallArmSpeed",-1f);
}
else
{
//anim.SetFloat("SmallArmSpeed",0);
}
//----------------------------------------------------------SHOVEL-----------------------------------------------------------------
if(Input.GetKey(KeyCode.Q)&& !Input.GetKey(KeyCode.A)&&(!changeShovelDirection || !nextShovelIsUp))
{
changeShovelDirection=false;
nextShovelIsUp=true;
anim.SetFloat("ShovelSpeed",1f);
}
if(Input.GetKey(KeyCode.A)&& !Input.GetKey(KeyCode.Q)&&(!changeShovelDirection || nextShovelIsUp))
{
changeShovelDirection=false;
nextShovelIsUp=false;
anim.SetFloat("ShovelSpeed",-1f);
}
else
{
//anim.SetFloat("ShovelSpeed",0);
}
The reset Script has:
publicvoidSetBigArmSpeed()
{
Debug.Log("bigarmspeedresetted");
excav.changeBigArmDirection=true;
excav.anim.SetFloat("BigArmSpeed",0f);
}
publicvoidSetSmallArmSpeed()
{
Debug.Log("smallarmspeedresetted");
excav.changeSmallArmDirection=true;
excav.anim.SetFloat("SmallArmSpeed",0f);
}
publicvoidSetShovelSpeed()
{
Debug.Log("shovelspeedresetted");
excav.changeShovelDirection=true;
excav.anim.SetFloat("ShovelSpeed",0f);
}