- Home /
Unexpected state transition in animator controller
I am having a problem with transition between states:
Character is having a plate and he is in a IdlewithPlate state. Now i want to put it back. So I set trigger "puttingPlate" which allows me to go into a put_plate state. This script is attacked to character :
void Update() { if (Input.GetKeyDown("1")) { if (anim.GetBool("havingPlate")) { anim.SetTrigger("puttingPlate"); } else { anim.SetTrigger("Grabbing"); } } }
and since he is in a state havingPlate he will perform puttingPlate, which shows below figure:
In order to drop plate(which is set its position and rotation to initial set), I have set event OnDrop() at the end of put_plate animation. The onDrop() in script looks like this:
public void OnDrop() { if (pickObj != null) { Vector3 distance = pickObj.transform.position - objectOriginalParent.transform.position; float magnitude = distance.magnitude; Debug.Log("Magnitude: " + magnitude); if(magnitude<= magnitude_set) { pickObj.transform.parent = objectOriginalParent.transform; pickObj.transform.position = objOriginalPosition; pickObj.transform.rotation = objOriginalRotation; anim.SetBool("havingPlate", false); } Debug.Log("HavingPlate: " + anim.GetBool("havingPlate")); } }
In this script my intention is to reset position of plate before picking up, and it works, because plate is placed back. The problem is that when I put it, character return to IdlewithPlate state, despite that condition for this state is set to "havingPlate" ==True. However my OnDrop() function should change it to false, and go to Normal Iddle_state marked on a first figure. What I am doing wrong?
Also a puttingPlate in a parameters tab, doesn't looks like it's triggered, however putting plate animation was performed because I see this animation in 3d view. This character is putting plate, but it return to state when he holds air, without plate.
Your answer
![](https://koobas.hobune.stream/wayback/20220612214720im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mecanim - How to figure out the State and layerIndex that triggered Animation Clip Event? 0 Answers
Easier way of creating transitions in the animator? 1 Answer
Animation speed and animation event timing oddities. 1 Answer
Can't Check If Animatorstate Is In Second Layer 1 Answer
2D Animation does not start 1 Answer