Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Motion Controller

Discussion in 'Assets and Asset Store' started by Tryz, Feb 21, 2014.

  1. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Coming back with some feedback on my tests

    I tried with the State Machine Behaviour and I didn't like the results I've got.

    I remembered I've worked on the custom event script that intercept Combat Messages and send them as a custom event into Bolt.

    So I did an expose combat message and saw that I have everything I need there. I can use the Attack Index to spawn different slash/hit particles depending on the attack, and even modify it based on impact power. Good, very good (love your message system Tim)

    So as a prototype (the final won't be an Expose and have lots of derivation depending on attack style/impact power - also instead of instantiate I'll probably use pooling) I've set a simple "launch the particle trail from the mount point "right hand" position/orientation and spawn a hit particle on the hit transform of the enemy"

    It works quite good, need to tune some stuff though.
    upload_2018-6-20_0-24-42.png

    My issue here is that I'm using the combat message: "MSG_COMBAT_ATTACKER_ATTACKED = 1101"

    It only spawn the particles when the attack is directed to an other actor combatant. For the Hit particles it's ok, but I'd like to have the slash trails even if hitting nothing

    Before I tried with the pre-attack message and from the video I saw it's clearly not the right one (it spawn particles as soon as I hit the attack button, too soon and even without attack animation going on)

    Then I tried "MSG_COMBAT_COMBATANT_ATTACK = 1002;" but it does nothing at all...

    Is there a way to have what I want in this case? Or would it require for you Tim to create a custom message?

    Thanks for your input

    Ah, also my second question from my first post is still valid (slowing down the end of an animation)

    thanks
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Personally, I'd spawn weapon particles and hit particles from the weapon. The SwordCore inherits from WeaponCore and provides the basis for melee weapons. By inheriting from SwordCore, you could override some key functions and spawn your particles:

    OnStartSwing(CombatMessage rCombatMessage);
    OnEndSwing(CombatMessage rCombatMessage);
    OnImpactComplete(CombatMessage rCombatMessage);

    The "CombatMessage" grows over time. So, by the time you get to OnImpactComplete, it includes the actual point that was hit, the defender, etc.

    While I haven't done particles like that yet, inheriting from SwordCore seems like the right place to start.

    You can slow the animations by changing the "Speed" property on Unity's animator component:
    https://docs.unity3d.com/ScriptReference/Animator-speed.html

    In the MC, you can access the animator off of the Motion Controller while in a motion. Like this:
    mMotionController.Animator.Speed = 0.5f;

    Just make sure you reset the speed as the animator will keep the speed for all animations it runs.
     
  3. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    I see what you're saying about it auto-starting when at the top. It makes sense because without the Action Alias, you're in a valid place to climb down.

    I think you'll want to customize a motion to not do the climb down automatically. What I'd do inherit from ClimbLadder.cs and then override the TestActivate() function.

    If you look at line 264 and line 271, you'll see two functions TestForClimbDownBack() and TestForClimbDownFoward(). You just want to prevent those from returning 'true' if you've just come from the Climb Ladder motion.


    If you don't want to create your own motion, you could do all this by tapping into the MC's Unity Events. For example, there's an "On Test Activate" event. You can create a small handler for that and change the message's "Continue" property to false if you just came from the Climb Ladder motion.




    I prefer the inherited motion route, but I get that may be scary for some.
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Weird this didn't show up until after I just posted. o_O

    That's really cool that you can tap into it from Bolt... nice. :)

    Ah. As you mentioned, the pre and post messages aren't really synced with an animation. They just trigger as the motion is activated or deactivated.

    There is no separate message pair for when the swing starts, but you could tap into the SwordCore as a I mentioned in the post I just sent.

    On thinking about it more...

    The problem with adding messages to the SwordCore.OnSwingStart or to the BasicMeleeAttack is that my animation events are occurring when the attack is valid to contact. That probably isn't the right point for a swoosh-arc particle system to start and stop.

    I think the best things for you to do is to add your own animation events to the animations you have. Then, you can position the start/end pair regardless of my 'hit' pair. You'd then have a component listening for those animation events and turning on/off the swoosh particles as needed.

    I haven't tried this, but I think that's the way I'd go to have full control over the start/stop.
     
    TeagansDad likes this.
  5. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    862
    I just recorded the height when the actor's velocity y turn from positive to negative. Then when he's about to land I check the delta height, set up several rules for like: when the delta height is smaller than 2 he uses normal landing; 2 to 10 uses hard landing and consume his stamina or health according to the exceeded distance from 2 meters; bigger than 10 he simply dies.
     
    Tryz likes this.
  6. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    862
    Hi Tim,
    I'm wondering how can I serialize a custom struct in one of my motion, I'll need to draw it on the motion controller inspector but found it can not be serialized, all modifications in the inspector will be lost when the memory is dis-allocated.
    Any API from ootii's editor extension that I can use?
     
  7. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi Tim,

    thanks for both your answers and ideas on this topic and on the animation speed, I'll try that at home

    I like the idea of animation events in this case! I can still use anyway the combat message for the Hit particle as it is clearly working great

    The only thing is that I never used animation event. I know how to set them (I have 4 motions that chain together in a combo, so I used those events, but those are set by you already) but I don't know how to listen to them.

    If it's particles with auto destroy or no loop, I believe I just need to set a "StartSwoosh" not an end

    Is there a simple way to listen to this animation event within MC or is it Unity stuff?
    I would just need a simple example so I can try to translate it into Bolt and have unlimited power (or not :D)

    thanks
     
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Necka_ likes this.
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Unfortunately, there's no good way to do this.

    MonoBehaviours don't allow lists of derived types and ScriptableObjects can't be stored as prefabs.So, I had to serialize my motion lists myself and that approach doesn't support new types. Over time, I've evolved how I serialize things but I haven't moved that into the MC because I don't want to break everyone's existing motion list.

    So, the best thing to do is store your information as an external MonoBehaviour on the character and then access that information from the motion using GetComponent<XXX>().

    [EDIT]
    Another trick you can do is serialize your struct into a string property and that will get saved. You would deserialize in the motion's Awake() function and serialize in the OnInspectorGUI().

    I haven't done this in a motion, but I do this in other assets. It should work.
     
  10. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi Tim

    Your last idea was very good, it works super fine and it is very easy to setup

    upload_2018-6-20_22-55-55.png

    I was just wondering (I'm not into code + how much this or that is expensive) if those animation events triggers are expensive and if it will follow up with multiple ennemies and fast paced action
     
  11. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    I've never done any performance tests on them directly, but they are a core Unit features. So, I'd assume you'll be fine to use them.
     
  12. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634

    if it was mobile, I would be worried about it, since its PC, I assume your fine. typically. Check the Profiler as well. but typically for PC your fine.
     
    Necka_ likes this.
  13. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hello,

    So I managed with no issue to create a whole 1 handed sword flow that just uses a different Form (8000 for the test)

    The only struggle I have is that the Equip Motion doesn't actually equip the Sword I have defined. It works if I set the Form to 100 in the inventory (but that's the wrong animation then), but when I set it to 8000 (and have also my Animator state with this requirement) the animation works, but the sword doesn't come out.

    So I'm missing a point that is probably obvious here. While I found out for IDLE, IDLE Pose and Exit, the new form blended tree, everything worked out, but just this point is a mystery for me now

    Here are my settings:

    upload_2018-6-21_14-47-25.png
    upload_2018-6-21_14-47-35.png

    Edit: also the other mystery for me is the Motion Phases definition. I saw for example 3150 and 3155 for the original sword and shield. I do not realise what those are and where they are defined; maybe it's actually my issue
     
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    If I had to guess, your new equip animation doesn't have an animation event at the time you want the sword created. If you look at my "draw sword 1" animation, you'll see this:



    That's the point in the animation where the motion creates the weapon you've defined in the weapon set.

    "Motion Phases" are just integers. I use them to control the flow of the animations/motions. They are the conditions on the transitions in the animator.

    Think of the "Motion Phase" as what we're doing and the "Motion Form" as the form that action will take. For example:

    Motion Phase 3150 says "Equip a sword"
    Motion Form 100 says "Equip a sword with Tim's animation."
    Motion Form 8000 says "Equip a sword with Necka's animation."
     
    hopeful likes this.
  15. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    955
    @Necka_ - Also check your transition time into your Equip animation. It defaults to 0.25s, but if you're still transitioning when the Animation Event occurs, it won't be received.

    You can see in the preview on the transition from Any State if this is happening. If it is, try a transition time of 0.1 to 0.15
     
    hopeful and Tryz like this.
  16. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Oh my god I feel so stupid right now. I did check the animation event because since our talk yesterday, I'm playing a lot with them and love it. But yeah, guess which animation clip I checked for event? mine :D of course there were no events... I'm sorry that was dumb :D

    But at least I won't forget that now, and I understand better the motion phases too

    @TeagansDad: thanks for that too, I need indeed to modify the transition speed
     
  17. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    I'm not sure how to manage this as I found the Animator.Speed function (if it's called a function) but nothing that is related to mMotionController.Animator.Speed (In bolt) maybe I'm not checking in the proper types (just checked in MotionController and also in MotionController.Motion

    My issue is that when I slow down the animation (at the start of the Combo chain) if the player press the attack button in the good timing I wanted that the animation speed reset; I'll probably need to be super creative for this one I guess
     
    Tryz likes this.
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,531
    Dialogue System for Unity 2.0.1 Now Has Motion Controller Integration

    Just posting a quick note that the Dialogue System for Unity now has support for Motion Controller, courtesy of developer Chris Lasting.
     
  19. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    That sounded very simple in my head, but I can't find in the documentation or on this forum how to adapt the BasicDamaged motion to play a different animation based on a variable (would be in my case the power of the hit, which I can already grab from a message)

    I have the player (attacker) who hit the defender with Slash1 and that plays on the defender the BasicDamaged motion and its unarmed animation. Ok good, but seeing the other animator states, I don't get how to have my own custom to play

    Like here:

    upload_2018-6-21_23-45-44.png

    So this will happen if the Actor in in motion form 100 (Sword and Shield), fine. But what are those parameters? where do they come from and what influences them?

    To test I just set on my Attacker to have the basic attack to have L0MotionParameter = 40 and I've set on the defender that it plays another animation when the parameter = 40.

    Of course that doesn't work, because the attacker Basic Attack parameter probably doesn't speak to the Defender BasicDamaged parameters

    I tried even to set manually in the BasicDamaged motion the form to something different with no success...

    So I'm a bit lost, I want to do something quite generic where all my actors will react to normal attacks with a normal damaged animation, but could be knocked back on stronger skills or even knocked down on even stronger skills.

    I maybe missed it in the documentation, but really I can't figure out what parameter I should change to influence the damaged motion.

    I don't think it's super complicated to translate the power of my sword attack into different damage animation, or am I doing it with the wrong logic?
     
  20. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    That's awesome! Thanks for posting. :D
     
  21. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    The LxMotionParameter parameters are generic. Meaning motions can use them however they want. I just found it was convenient to have one generic parameter than a specific values for every motion.

    With my Basic Damaged and Basic Killed motions, I took the approach that I'd change the animation based on the direction the hit came from. So, being hit from the front has a different damaged animation than being hit from the back. With the motion packs, I used L0MotionParameter to be the angle the attack came from. That's why you see the conditions in your image.

    Here's the flow...

    In the WeaponCore.OnImpact, I send the combat message to ActorCore.
    In the ActorCore.SendMessage, I send the combat message to the BasicDamagedReactor.
    In the BasicDamagedReactor.Activate, I send the combat message to the MC and BasicDamaged picks it up.
    In the BasicDamaged motion (line 257), I activate the motion and set the parameter as the attack angle.

    So, changing the damaged animation as related to my attack angles is easy. You're just doing what you've been doing with the animation replacements.

    The reason for these steps is so you can hijack the combat message at different points and modify or cancel it. The reactors are where you really want to make decisions.

    To do this, you're going to create your own "damaged reactor". With that, you can start to make some decisions and activate different motions.

    For example, your reactor could evaluate the combat message and if the damage is less than 10, you do what my Basic Damage Reactor does. If the damage is > 10, instead of activating my "Basic Damage" motion, you activate my "Pushed Back" motion. If the damage is > 100, you activate my "Knocked Down" motion.

    Pushed Back and Knocked Down are different motions than Basic Damaged. I did it this way so you could create new motions with new animations... Maybe you want one that flies you back in the air or kills you instantly.

    The reactor is the thing that you use to determine how to "react" to the combat message. It's where damage is applied and the motion (animation) is started.

    I hope that makes sense.

    With this, you can customize the damaged reaction, the damaged motion, and/or the animations how you see fit. :D
     
    Necka_ likes this.
  22. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    That does make a lot of sense and I totally can imagine (I think) how to manage that now
    Thanks!

    P.S: You should sometime copy and paste this kind of answers in your documentation website :D - but personally, I'm going to bookmark this answer for future reference

    Instead of creating another topic I'd like to ask a question that is more about organisation in the editor UI: I think I've seen some people speaking about that some posts ago.

    I've started to use your advice regarding not creating another Basic Melee Attack motion and just used different forms for different attack style (1H Sword, Axe, 2H Sword... whatever) It works for sure!

    But the issue is that when adding the many different animations (attack style) to the list, it start to be really a lot, and code wise it's referenced only as Index number; so first the list is becoming way too long and the other issue I see is that let say I've added 8 1H sword attacks, 6 Axe and 9 two handed sword attacks. I now get Index 0 to 22.

    If I decide to add a 7th Axe attack, it'll be the 23rd, except if I move it up in the list (which is possible) - but then, I personally have some "code" that check the attack index to spawn different particles (or it could be anything else)

    I guess that could be some improvement for the future versions?

    But more than that, could there be some kind of unique ID for an attack style that can be grabbed by the combat message system? so instead of using the Attack Index I'd use the Attack unique ID or something like that, so I don't lose the reference just because of organisation ^^

    Hope what I said made sense, and shame on me if there is already a way to deal with that
     
  23. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Great point.

    How do I choose how to react to an attack?

    This is an issue @TeagansDad brought up a while back too... and you're both right.

    I can totally see where it can become an unwieldy mess. It's at the top of my list to clean-up once my contract job is over (in a month or so).

    @TeagansDad had a great custom solution that I'll probably steal. ;)

    He created "Attack Style Sets" from scriptable objects. So, he'd have a set for swords, a set for axes, etc. When the Weapon Set is equipped, he destroys the current list of attack styles and resets them based on the Attack Style Set associated with the Weapon Set.

    I think that's a super smart (and clean) solution.

    So, definitely something for me to clean-up. I just have to get the time.
     
    hopeful, TeagansDad and Necka_ like this.
  24. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    I love it :)

    Wow yeah that sound actually really like something I'd use right away,

    trying my luck meanwhile :D @TeagansDad is there a chance you could share this now? or would it be not suited for sharing?

    @Tryz What about having unique IDs per attacks, could it be considered too?
     
    Tryz and TeagansDad like this.
  25. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    955
    Sure, I can do that. I've been doing some significant refactoring and clean-up on my Motion Controller support library, so I just need to make sure that the custom inspectors for those classes still work. :)

    I'll see if I can send you something tonight (I'm on Pacific Time).
     
    Last edited: Jun 22, 2018
    Tryz and Necka_ like this.
  26. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Thanks a lot, I'm on Central Europe time but I usually work on my project all night during the week-end ;)
     
  27. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hello,

    I know Tim won't have time for that but maybe some people here already create such thing.
    I'm really lost on how to create a Reactor to handle knock-back and knock-down

    Is there anyone who would have such reactor with little explanation on how to make it work?

    My goal is (I could tune it if I understand how it works then) to have the character knocked back if the Impact power is sufficient

    I don't even know how to trigger simply the knock back on any damage, it has a specific motion phase

    I though there would be a simple way with already existing messages that would allow to send a message on hit: knock the defender back, but I didn't find such thing

    My current system works like that at the moment:



    I want to try to play with the knock back because most of my attack animations are no in-place and the defender staying in place when damaged makes it quite difficult to chain multiple combos

    @Tryz : if I can't manage to play with the knock back how I want (I think I'm going to be blocked by the fact that if the attack comes from behind, then the knock BACK will do the opposite effect of what I want. I was wondering if there is a way to have the player always look and attack in the direction of the defender? - the targeting system should be the way to go, but the body orientation doesn't update after an animation. Not sure If what I'm explaining is clear though
     
  28. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    955
    @Necka_ Sorry, didn't get a chance to put those files together last night; I should be able to tonight.

    What Unity version are you using? Now that the .NET 4.6 runtime support is out of experimental status (in Unity 2018.1) I've started using C# 6 features. I don't think I've updated the code in question yet, but I'm not totally certain.

    I can help you with those reactors for triggering a knockback.
     
  29. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    I'm using 2017.4.5 but I'm on NET 4.6 already. I'm waiting for 2018.2 to switch over as I'm only in prototype phase it's not a big deal

    For the knockback that would be really kind of you
     
  30. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    First... Your video is looking really good! :D

    Think of the reactor as your decision maker. I'm not really sure how you're passing "Impact Power" through, but lets just assume you're going based on damage for now.

    To keep things simple, let's just modify my BasicDamagedReactor.cs directly.

    All you really need to do is this:

    1. Make sure your enemy has the "Knocked Down" motion and "Pushed Back" motion in their list.

    2. Modify BasicDamagedReactor.cs like this:

    At line 121, inject the following:
    Code (CSharp):
    1.             // Pushed back motion if damage is more than 10
    2.             else if (((DamageMessage)mMessage).Damage >= 10f && ((DamageMessage)mMessage).Damage < 100f)
    3.             {
    4.                 MotionController lMotionController = mActorCore.gameObject.GetComponent<MotionController>();
    5.                 PushedBack lMotion = lMotionController.GetMotion<PushedBack>();
    6.                 lMotionController.ActivateMotion(lMotion);
    7.             }
    8.             // Knocked down motion if damage is more than 100
    9.             else if (((DamageMessage)mMessage).Damage >= 100f)
    10.             {
    11.                 MotionController lMotionController = mActorCore.gameObject.GetComponent<MotionController>();
    12.                 KnockedDown lMotion = lMotionController.GetMotion<KnockedDown>();
    13.                 lMotionController.ActivateMotion(lMotion);
    14.  
    15.             }
    16.  
    With that, the logic would be:
    a. If health <= 0... play the death animation
    b. If damage >= 10, but < 100... push back
    c. If damage >= 100... knock down
    d. If damage < 10... play damaged aniamtion

    You can get a lot fancier, but that's all you really need to do.

    The PushedBack and KnockedDown motion will automatically have the character recover.

    With this approach, the direction of the attack doesn't matter since the damaged motion doesn't play unless the damage is < 10.
     
    Necka_ likes this.
  31. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    This is crystal clear to me, thank you so much.

    <Funny story time>

    I'll probably try to make it its own reactor file though... yesterday I cried a little... when I started my prototype the first thing I did was to duplicate the Animator to avoid having it replaced by an update. Funny part though is that I didn't assign it to my character.

    I noticed it and every day I was like "Oh yeah, I need to duplicate this one that has all those custom Combat animations; will do that after" of course I never did.

    And guess who clicked on "import" to get the last Motion controller update from the store ?? I realised as soon as I pressed import.. I think I was very very pale. Took me 2 hours to redo everything :(

    <End of the funny story, back to noob stuff>

    I understand what is going on in the code, even though my problem is that I wouldn't know how to write it myself, to put the pieces together if you want. I got the logic, I know what is needed but not how to write...

    That's where I like visual scripting. But it can't be used everywhere, like here for something that needs to be integrated within the core.

    For the impact power I got it from your message system, but going with health make sense to me as I was a bit struggling to modify the impact power at runtime (didn't dig much though).
    Does the impact power has any utility in MC actually? I know that a lot of things aren't used (like the LXParameter which I now use to define the colour and size of my impact particles ^^)

    Quick question regarding the "Hit position" it's related to multiple enemies.

    Let say I do a spin attack that hit 3 ennemies. Will the message system answer me with 3 hit positions (1 message on each defender) ?

    The more I use MC, the deeper I go and the more I love it :D

    But if in the future you'd implement some drop down menus to handle "basic" things used with reactors that would be cool. I just speak about things like knock down/knock back - not necessarily advanced reactors of course. But maybe you really want to keep it so it can be tailor made of course.

    Thanks again
     
    Tryz likes this.
  32. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Didn't start to work with the Knockback/down reactor and focused on the multiple targets issue I have

    So I've made a test regarding this point

    To explain how everything works and maybe because some people are interested in Bolt (or for future references)

    If you are not interested by the full explanation you can skip to the end and see my "AOE" problem (hitting multiple targets)

    I've got this Bolt flow just for the "Slash" spawning, on my Player (Attacker in this case)

    upload_2018-6-24_4-43-16.png

    It's probably difficult to see anything but if anyone is interested I can make another post detailing everything

    For the high level overview for those interested (and also for you guys expert who could probably tell me that there is an easier and more flexible way to do it, I'm interested):

    In the start function I set all my particles in a list (it's checking a parent that is my particles pool in the hierarchy)

    Then the next long function (if it's called like that) is triggered on animator event: I've set on all my attack animations a trigger event at the moment a Slash should spawn

    Then I get from the "BasicMeleeAttack" motion the L0Parameter (all my attacks declare this parameter)

    The parameter defines the slash colour, size and angle (from 0 to 99 it's Green and Small size, from 100 to 199 it's Orange and Medium size, etc) then if the number ends by 1 it's a right to left slash, 2 is left to right, 3 bottom to top, 4 top to bottom)

    I've made it in this way so later if I put more "skills" like a Fire slash, I can just add a line in the flow check for 111, 112, 113, 114 which will then decide the same.

    The good thing with that is for the player it's just the L0Parameter that will be updated at runtime depending on the skill he activates (@Tryz I'm sure you were curious to see some of your customer get creative with this parameter ^^ please never remove it lol)

    So the whole flow will go through a path to construct a final variable made with some substrings to craft for example "Orange + Medium + Slash" (got the same for Hit particles constructed with Hit instead of Slash)

    At the end it is just doing a Foreach loop in the list and get the item that contains this constructed string, instantiate the Slash at the player position, change the rotation depending on the angle variable defined before and finally activate the GameObject (which auto destroy after 2 seconds)

    So that's for the player.

    For the Enemy (and that's where I need help) it's just about getting hit and spawning a particle where it was hit:
    upload_2018-6-24_4-55-5.png

    The event start on a trigger when the message 1107 (On Damaged) is sent by the Actor core.

    From "Combat Message" I'll get the Hit Point as a Vector3

    Then I just construct my Hit Particle based on what was the player slash particle (so I just grab the final variable from the Player flow to get the Colour and Size) then I do the same, search in the list to get the proper Hit particle and instantiate it at the "Hit Position"

    So here is the issue: I have issues getting multiple ennemies hit at the same time. It works sometime but most of the time even though my Field of attack (set on each attack style, quite big to be honest) clearly touch them

    I've made a clear video showing that issue:
    (I don't get the Field of Attack shown though but in the editor it was ok)

    I don't have any collider or rigidbody on my weapon as I wanted to use the FOA.

    Sorry for the long post, but I thought it would be also good to show my "logic" for this situation, also I do start to get the hang on Bolt, so if anyone needs some help with Bolt + MC I probably can provide some support (the community gives so much, I'd like to give back too)
     
    Tryz likes this.
  33. Flaring-Afro

    Flaring-Afro

    Joined:
    Jul 20, 2015
    Posts:
    14
    Just bought this asset and I'm having trouble with it. I created a new scene, made a plane that is 100,1,100 in size, and dropped in the player bot that came with the package. I then click the bot and, like in the video, I click component>ootie>motion controller and then click MMO. On play, the character shoots into the sky and back (Z going into negatives) with no input. If I turn the camera with right click, the bot keeps moving the direction behind it. I thought it may have been some kind of crazy collision issue so I raised the bot a little off of the ground and the same thing happens. There's no other scripts in the scene and no errors, I'm not sure what I could be doing wrong :/

    Edit: Also, I'm using 2018.1
     
    Last edited: Jun 24, 2018
  34. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Ok so I'll need to check how to make custom animation for the push back (not asking for help here - would like first to get help on my multiple enemies hit from my previous post)

    But you gotta admit that my ennemies are actual worse actors than Neymar at the World Cup:



    :D
     
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    That's odd. I just created a new Unity 2018.1.0f2 project and imported the latest MC. Everything was fine.

    I followed the setup instructions here (page 2 & 3):
    http://www.ootii.com/Unity/MotionController/MC2Guide.pdf

    I then created a new scene like you said... no issue.
    1. New scene
    2. Added Plane
    3. Set Plane scale to (100, 1, 100)
    4. Dropped in my Proto character
    5. Added the Motion Controller to Proto
    6. Clicked MMO Style button
    7. Hit play

    Did you try the demo scenes (page 2)?

    Did you put the camera as a child of the character?

    Did you put a rigidbody on the character?


    It sounds like this is unique to your setup. Go ahead and email a screen shot of your Hierarchy and character inspector to tim@ootii.com. That might help me to see what you did.

    Thanks.
     
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Based on what I can see in your setup, I think your BasicMeleeAttack.cs is using the CombatantManager's QueryCombatTargets() function using your attack style (line 597).

    It could be that the first test of the area really does only hit one character. We get a result and then no other test is made until the next swing. I did this because it made sense (to me at the time) that a swing would only damage the first person hit and not 10 guys. I get that might be too limiting.

    You can see where I turn off the weapon hit at line 607 of BasicMeleeAttack.cs.

    Since we're dealing with customized attack styles and multiple custom characters, you're going to have to walk through the code to see why multiples aren't always getting picked up. It could be what I said above or that they aren't on the same collision layer, they don't include the right tags, etc.

    Another thought... the RaycastExt.SharedColliderArray allows for a max of 40 collider hits. So, if your characters have lots of ragdoll style colliders on them, you could be sucking up the 40 spots quickly.

    The Combatant.QueryCombatTargets() is at line 90 of the CombatManager.cs.

    Unfortunately, there's so much customization going on there's just no getting over stepping through the code at run-time and looking at what's in that QueryCombatTargets() result.
     
  37. Flaring-Afro

    Flaring-Afro

    Joined:
    Jul 20, 2015
    Posts:
    14
    Just made a new project, imported (did not redownload), and it worked. I looked back at mine and the demo works but not the new scene still. I made a copy of my project and deleted everything but the scene and the ooti folder, same issue. I then deleted the Library while Unity was closed and opened it up again. I got a lot of import warnings and errors. It behaves the same. I don't remember the errors the first time, but it's possible I cleared it without paying attention because at work I'm on a project where that happens but everything works fine (to give you an idea of how horrible the project is XD).

    I'll email you the project and a screenshot of the errors in case it's helpful for you in the future, then I'm going to delete the ooti folder and that scene in my project and try importing it again.

    Edit: Reimporting it fixed the problem
     
    Last edited: Jun 24, 2018
    Tryz likes this.
  38. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Thanks for that info

    the characters are all basic characters with just the Motion controller + SSMP, no additional setup like colliders or else.

    They're all on the same layer and tags, actually I didn't setup anything here..

    The sword core is setup with large Fields of attack; but no Colliders/Rigibody. Would it be needed? I thought without them the fields of attack prevail

    Does this issue has anything to do with the "Hit" animation event that should be duplicated multiple times to hit the targets that collides as the slash goes?

    I'm more on a hack and slash style, so yes a single target is definitely a big limiter in that game style

    Edit: Added a box collider (giant style) and rigidbody set to kinematic and the multi target hit is working. Does it mean I don't have to care about FOA when setting my attack style? if yes, should I remove the FOA start and End in animation events for optimisation purpose?
     
    Last edited: Jun 24, 2018
  39. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    862
    Hi Tim,
    I've encountered a small issue with motion controller:
    I want to let player's rotation be saved when he quit the game, and load game with the exact same rotation when he left.
    But found the actor controller always loaded as the default rotation, by debugging I found that my loading method did set the rotation of the character but then he got dragged back to 0 rotation.
    Any ideas where should I look into?
     
  40. BinaryStylus

    BinaryStylus

    Joined:
    May 9, 2018
    Posts:
    3
    Dear all,

    TL:DR; Does Event System - Dispatcher come with the combat motion pack?

    I'm taking baby steps. I'm finding my Unity experience quite fun. I'm getting on really well with the Motion Controller. But I'm taking it slow! Although I've bought the motion packs I've not played with them yet. There does seem to be a lot you can do jut with the Motion Controller. At the moment I'm just having my character run around an assault course I've made - basic locomotion stuff - I'm loving it. I've got my character to moon walk with a custom stance - etc.... But I'm messing around with "events" that happen on my assault course demo...

    Maybe someone can help me and Save Tim a post. The Ootii product catalogue is awesome. I want the Event System - Dispatcher - I'm super used to C#'s MVVM programming convention / windows message queue and Tim's obviously made a nice implementation of that sort of thinking. So; I'm going to want the Event System - Dispatcher - but do I actually already have it? Does it come with the Sword and Shield combat pack. (Please don't get me wrong; I'm only thinking it might come with that - because there is lots of discussion of "events" in regard of it). [I want to use the Event Dispatcher probably before I get into the Combat Packs and making characters fight - I'm just having so much fun with my assault course....!]

    Cheers all,
    Tim (I'm another Tim)
     
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    The AC is managing the character position and rotation internally. If you want to force a position or rotation, you'll want to use:

    AC.SetPosition(<vector3>)
    AC.SetRotation(<quaternion>)

    They will immediately update the transform and set the internal values as well.

    I use these internal values to manage the velocity, rotational velocity, distance traveled, etc.
     
    Harekelas likes this.
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Welcome @BinaryStylus

    No it isn't included. The Debug Logger asset and Actor Controller are, but not the Event System.

    If you own the Event System, I will send events with it.

    I think that's the exact right approach. Especially if you're new to Unity in general.

    You're going to find there's a LOT of included pieces (attributes, inventory, reactors, cursor visibility, etc.). Take the time and explore. :)

    It doesn't come with it, but it's also not required. In a lot of places (like at the bottom of the Motion Controller), I include event hooks using Unity Events. I've found this to be a great way to create your event flow and it's obvious as you can see the linkage in the editor.

    I would say keep playing around.

    I think the Event System - Dispatcher is a great tool, but it's not a very visual approach to event handling. Since you're used to C#'s MVM, I'm sure you'll be fine. However, don't feel you have to. :)
     
  43. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    That's exactly right. You can go the non-collider approach and the FOA will be used.

    You want those events. Think of those events as turning on the FOA and then turning it off. This way you don't hit someone with your sword while it's pulled back in preparation for a swing.

    In that code I mention, I do automatically turn off the FOA when I find a hit. However, the code should handle multiple hits as I loop through everything in the sphere and compare it to the FOA.

    If I had to guess, the extra character's aren't really in the FOA due to a rotation or something. This is why I mention that stepping through the code is important. You'll see why either Unity didn't pick up an extra character or why I ignored it. The logic looks right to me, but the situation may be off.

    Unfortunately, I'm a bit buried right now and won't get to playing with it myself until the end of the week.

    So, that makes me think that your extra targets really weren't in the FOA. I'm doing an initial Unity sphere test. So, if Unity's physics doesn't pick them up, I can't process them. If it does, I get the closest point on the collider and if that's not in the FOA, I toss it.

    That's why stepping through your exact situation is so important. You can see the exact reason an extra target may be tossed.

    Keep the events. You need them as the on/off switch. :)
     
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    It's definitely something with your scene setup then. I saw you emailed me and I'll take a look at it once I get some breathing room (today or tomorrow).

    I'm using Unity's animations in the MC and they have lots of warnings. You can just ignore them. I HATE seeing them, but their animations are free and way better than what I can do. :)
     
  45. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Ok, I think I got it, I'll be humble and state that I won't be able to go through the code and understand everything that is going on :) but I'll play a bit more with box colliders to see how to have an optimal setup. Hitting targets properly is very important in my game combat optimisation, I don't want it to be random, it has to do what it is supposed to do for the player (having skills that can hit multiple targets)

    Just to understand and be sure: If I use a box collider + rigidbody on the weapon, will the FOA distance range and angle still count (to know if it worth the time setting them up perfectly)

    Also I'll do another test tonight with only the FOA and adjusting the angles and range way more :)
     
  46. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    862
    I also use your camera controller asset, and would like to set the initial rotation of the camera, it also doesn't seem to work if I directly set the rotation of its transform. And I don't find a SetPosition function in the camera controller or the motor.
     
  47. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    When you walk through the code for your specific scene and situation, it's not really about understanding the code. It's about watching the variables and looking at why a target gets chosen or not chosen. I'm confident you'll understand enough to see why something wasn't kept.

    The BasicMeleeAttack was never purposely built to hit multiple targets at once. That isn't to say it won't, but I didn't purposely build it that way. It was built to hit a single target and stop which is closer to the real-world... that is what I was going for when I created it.

    You're using it in a creative way I didn't really plan for, but that's cool. It just means you're in uncharted territory. :)

    That's why you stepping through the code and seeing how it works in your situation is important. You may see the reason why you're not getting multiple hits as cleanly as you want. If you find something that should change to better support your specific situation, I'm open to making it for everyone.

    They still count because I still turn the collider on/off so we don't hit something at a weird time.
     
    Necka_ likes this.
  48. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Each of the camera motors has a specific function for positioning the camera. For example, the 3rd Person motors have a focus point (anchor + offset) and a radius (distance) that the camera orbits with. So, it doesn't really make sense to set a random position or rotation as it would violate the goal of the motor.

    In the case of the 3rd Person motors, you can get the motor and use the SetTargetYawPitch() function. Setting the yaw and pitch of the camera wouldn't violate the goal of the motor as it would still stay on the sphere that orbits the character and look at the focus point (anchor + offset).

    Code (CSharp):
    1. CameraController lCameraRig = gameObject.GetComponent();
    2. YawPitchMotor lYawPitchMotor = lCameraRig.ActiveMotor as YawPitchMotor;
    3. lYawPitchMotor.SetTargetYawPitch(0f, 0f);
    If you want to force the position or rotation of the camera to something trandom, you've got a couple of options:
    1. Disable the Camera Controller and move/rotate as needed.
    2. Use a "Camera Anchor" as the focus of the camera and move it.

    This post should explain the Camera Anchor more:
    https://ootiigames.com/?page_id=1079
     
    Harekelas likes this.
  49. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    The reason it didn't work in your scene is that you nested the camera under your player:


    That was something I asked about in my response:
    With my assets, you don't want to nest the camera inside the character because it creates a "feedback-loop". The character moves... so the camera moves... so the character moves... so the camera moves, etc.

    I'll make that more clear in the documentation.

    I keep the camera rig as a separate object which gives us a ton more control. :)

    Once I moved it out from under the PlayerBot, all was good.

     
    TeagansDad likes this.
  50. luekio

    luekio

    Joined:
    Jan 23, 2018
    Posts:
    24