edited May 2021 in ORK Support
Hello!
So I've been through some tutorials and now I wanted to add mecanim animations instead of legacy (since I'm using a custom player prefab with my own movement script). It's a 2d project btw (side scroller). I've set up everything like explained in the mecanim tutorial. Movement works fine and the Damage animation also work. But my attack animations does not work and I couldn't figure out why. I've checked mutliple times and the setup seems to be fine (Animation type is Attack, state name is Attack, Parameter is attack and set to trigger and in the anim controller I have the transition from Any State to Attack with the condition "attack". and in the Player combatant the animation type is set to Mecanim with the "Default Mecanims" animations and use Battle is disabled.)
I hope to get help here.
Thank you in advance!
Post edited by Perion on
  • The Mecanim tutorial is just one possible setup - e.g. you can disabling using ORK's auto animation and feed the movement speed to a parameter instead (via the Auto Move Speed Parameters setup in ORK's Mecanim animation setup).

    Try using Cross Fade play mode instead of parameters for the attack (and other) animations.

    Generally, it's sometimes a bit harder to use Mecanim, since there's effectively no direct control over it and you're at the mercy of it's state machine. Something that can also help is to add a short wait time between stopping movement and playing the animation in the battle event to give the animator time to switch state to idle before playing attack, otherise the idle animation starting might overrule the attack animation. E.g. a Wait node with 0.1 second wait time.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited April 2021
    I've already tried changing attack to Cross Fade but it didn't work.

    How exactly should I do that Wait setup? Do you mean that I should make a state in the Animation controller that first goes to the "Wait" state and after 0.1seconds to the next state (with exit time for example)?

    EDIT: Ohhh wait... My bad. I think I need to do the Battle Events tutorial to make animations like attack work xD I will try that and give an update if it worked or not.

    EDIT 2: Well it seems to work but it's like... the player moves to the enemy, applies the damage, moves back and then plays the attack animation
    Post edited by Perion on
  • Make sure you animate the correct actor - the attack animation is usually played on the User actor of the battle event :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited April 2021
    Yeah the actor animation thing was a bit my bad I forgot that I set the same animation for a few states because I hadn't created them yet. Now everything looks fine but like mentioned in my edit now the player plays the attack animation after he gets back to his position. I just deactivated the Wait Time in the Combatant Animation node in the attack event. If it's active the player is not playing the attack animation at all

    Alright now I'm confused... it suddenly has the same result with "Wait" Enabled. So yeah I only need to somehow fix that thing where the animation is played after the player moved back
    Post edited by Perion on
  • edited April 2021
    Well, due to Mecanim not reporting any animation durations back when playing (or attempting to play) animations, the Wait option here relies on the settings you made in the (ORK) animation setup, i.e. the Duration Type.

    You can either set a Fixed time or get the Animation Clip duration by specifying the name of the animation clip.

    There should be a yellow warning icon above these settings in the animation setup to explain this :)

    Edit: I should probably add that information to the Mecanim tutorial ...
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited April 2021
    So to maybe make things a bit more clear I just took 2 short videos showing the issue.

    This video shows my setup in the ORK Framework for the animations and events:
    https://streamable.com/grf653

    And this video shows the gameplay result:
    https://streamable.com/s5deuq

    As you can see, somehow while attacking the animations are only showing a few frames and they seem like they are frozen in that frame. Maybe I did something wrong in the setup so would be great if you could take a look at it and see if you can find something :D Tried to apply everything you told me. Maybe I understood it wrong and made a mistake

    (Oh and yes the Run animation is using the same animation as walk so the animation clip names are the same. And don't mind the weird offset of the combatants I probably need to play around with the offsets a bit)
    Post edited by Perion on
  • edited April 2021
    I'd say this is most likely in your animation's setup or in your animator (i.e. not in ORK), as ORK just plays the animations (or tells Mecanim to play them). Maybe check this with having the animator opened to see what's going on (while having the combatant's game object selected).

    It looks like either the attack animation keeps starting or the used animation is just like that.

    Also, since you only wait for 0.3 of the normalized time when playing the animation, if you wait for the attack animation to finish before moving back, you have to use a Wait node using the remaining time you stored. The setup video doesn't show if there is one in the event and the other looks like if the combatant immediately moves back after calculation.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited April 2021
    https://ibb.co/0B8s2d1

    There is a Wait node in the attack event but I don't know if you meant this one.

    EDIT: Alright so I had an idea... I thought maybe it does actually work but since the animation itself is so short it looks like it doesn't. So I just streched the starting and ending frames of the animations for a few more frames and yes... it looks like it actually does work. After testing around some more I realized that some other animations such as the cast animation are not playing though

    EDIT 2: Alright changing those animations (like victory, use etc.) to Crossfade seems to work :D

    2 Problems I still have though.
    One is that the Enemy keeps playing the run animation even if it moved back to its position (the enemy is using the same animation controller as the player). My assumption is that the enemy is using a character controller but I'm in a 2d space so the CC doesn't work properly I think.

    The other problem is that I can't place the enemy on the ground properly. When spawned the enemy has it's correct position but something is happening in "Run to base" event I think what makes the position so weird. I tried using an offset for the y Position in that event but that didn't change anything.

    EDIT 3: I found out that the combatants are playing their run animation until it's their turn. Once it's their turn they switch back to the idle state.
    Post edited by Perion on
  • Try enabling Use Position Change in the combatant's movement settings, this'll calculate the movement speed from position changes per frame instead of relying on a combatant controller, rigidbody or other similar components - that might get rid of the run animation issue.
    If not, you can always try to play the idle animation at the end of a combatant's battle events :)
    It might also be something in your animator's setup, though, e.g. no transition back to idle or something like that.

    As for the placement - the tutorial's run to base event will return to the battle spot of the combatant, i.e. it'll use either the positions you've defined in Battle System > Battle Spots (relative to the battle's game object) or you can also set specific positions by using game objects in your Battle component's setup.
    In any case, the battle spots during battle are actual game objects in the scene (usually parented to the battle's game object), so you can check in the scene view if they're placed correctly.
    Since you're using 2D, you probably shouldn't use any place on ground settings here. Also, check out the general how-to on 2D games :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited April 2021
    Position change is already enabled. And in the tutorial there was no transition back to idle so I thought that's probably not needed. Still tried it but didn't really fix the issue. Fixed the placement problem by disabling set to ground and just changing the offset of the enemy combatants spawn position.

    Here is a video showcasing the animation issue that I tried to explain but it's so weird I think seeing it is more helpful.
    https://streamable.com/tmgh9t

    And this again is the event setup. I tried adding animations for runToTarget.
    https://streamable.com/r430cg

    I tried connecting the change position to animation, didn't work so I tried it the other way but still not working. I don't know where I should add the Idle anim node that you told me at the end of every battle event. Should I do it after the "Wait" node in attack event for example?
    Post edited by Perion on
  • Hm, if you're using auto animations, playing the run animation in the runToTarget event isn't needed and might just be what's causing this.

    If that's not it, try not using auto animations and feed the move speed of the combatant to the animator as a parameter as I've mentioned in my first post. That'd allow the animator controller to handle this as it's (probably) normal to do in Mecanim :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • How exactly should I do that? I've tried to follow your instructions now. I disabled Auto Animation for the combatant and in Base/Control > Animations > Mecanim Settings is enabled Set Horizontal Speed and named the Parameter "movement" (the float parameter in my animation controller has the same name). Then I Added a Parameter (Play) in the Walk and Run animation and changed the Parameter Name to "movement" changed Value Type to float, Add disabled and Float Value to 1. I also made a transition from idle to walk and run with the paramtere "movement" greater than 0 and less than 0. Though now the walk/run animations never play.

    Have I forgot something? Sorry if I missed something in the explanation :D

  • If that doesn't work should I maybe try custom animations?
  • Ah, sorry for not being clear on that point - forwarding the move speed to the animator controller is meant to have the controller's state machine handle movement animation, e.g. via a blend tree.

    With such a setup, ORK no longer plays idle, walk or run animations automatically, i.e. you don't need to set it up in ORK (unless you want to be able to play them directly).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited May 2021
    Oh tank you very much :D The animation problem finally got fixed. And I just finished the Real Time Combat tutorial but somehow it's not working properly. The enemy is always doing nothing and if I open the Battle Menu with Left Control the Attack button is greyed out. I tried using the attack key (which is Tab for me) but nothing happens. I might check everything again if I did something wrong but I as far as I know everything should be fine.

    EDIT: Alright it was my bad xD in the enemy spawner I forgot to set the faction to Enemies.

    I don't know why exactly but the enemy and me are taking no damage from attacks. I've checked everything again and the setup seems fine. I'm thinking that it is because the weapon is not triggering properly but I don't know. I'm in a 2d space so what I did was I removed the rigidbody and box collider from the weapons and added a Rigidbody 2d (set to dynamic) and 2d box collider (and set the collider to is trigger). The tag of the weapons are set to "weapon" but they still are not working. With abilites I can kill the enemy so it has to be something about the weapon.

    EDIT 2: Ohhh alright I see. The problem was that since it set to Trigger Enter it didn't work. The Collider was too big so to be in attack range I had to be in the collider. I resized the collider so that the swords collider actually triggers with it and yeah now it works!

    Anyways, since the Animation problem is solved, for further issues I will create a new thread. Thank you for your help! :D
    Post edited by Perion on
Sign In or Register to comment.