Hi, I´m making a 2D top down game where I´m animating a box collider with the record button to use as a hitbox for the player´s attacks. it works fine in the preview, however, once I enter playmode the hitbox animation gets reversed (it moves up when I want it to move down) I would like to know if I´m doing something wrong or what may cause this issue.
Tried this and I can't reproduce the problem. By adding a sprite with a 2d Collider I was able to record movement that works the same way in preview and inGame. Any rotations(collider rotates with gameObject), other animations or scripts that could make this effect?
I thought so too: I had a script that made the character flip (since is simetric) and adjusted te box collider
size and offset (to take into account a transformation mechanic) however, I comented every line that deals with the collider and the fliping and its still happening. Don't know if it has any effect but:
1: the "attack hitbox" collider and the "collision" collider are in the same gameObject, they are just different types (box collider and capsule collider in that order) to make sure I'm not edditing the wrong one.
2: since the base animation layer was getting to complex, I put the attack animations on a second layer (it's the first time I try to use animation layers in Unity, I know they are mainly used in 3D but they seemed like what I needed to make the animator easier to trouble-shoot)
I'm not too familiar with animation layers either. I tried this. I added capsule collider too which had no effect. I first made the statemachine to base layer with animations up/right/down/left/idle and handled transitions thru int parameter. All work as expected. I then transferred the statemachine to a new layer and left only the idle animation to the base layer. My idle had the effect of size-transformation and I could see how the base layer iddle and new layer up/down/left/right blended according to the Weight setting in layer settings. Result is that animations played in either base or new animation layer work like in animation preview.
Make sure there is no other animation playing that affects the colliders position at the same time as the target animation since the blend of the animations can have undesired outcome and also that the correct animation is played when triggered.
ok, I fixed it, there wasn't any other animations affecting the collider but it had to do with the animation layers, I had set the "attack Layer" blending type to additive, (since it looked like the type I needed) setting it to override fixed the issue. thanks for your help