Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Motion Controller

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

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    Unfortunately, I haven't used Emerald AI. I'm not sure.
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,818
    Well, that's the point of the question. What I mean is, is there something specific to a Motion Controller AI Combatant that has a bearing on this? So that if it's not an MC Combatant that it might cause an issue.
     
  3. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    Well, that was the point of me giving you the file, function, and line number.

    No. If there is no MC Combatant, that's fine.

    For example, I took everything off of my Enemy(0) in the demo_SSMP and a super close hit still registered. The only things on the Enemy(0) were a transform, animator, and capsule collider.

    I stepped through the code starting at the file, function, and line number I gave and everything seemed right for my example.
     
  4. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    141
    Ah I see, thanks for clarifying!
     
    Tryz likes this.
  5. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    119
    How do I integrate A* Pathfinding with the MC? I've read hundreds of posts, read the docs and am more confused than ever.
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    1. Simplest approach
    Setup the MC with the Walk Run Strafe motion and check the "Use Transform" option on the Actor Controller.



    With this approach, you'll use A* Pathfinding however you normally do. When it moves the character's transform, I'll animate the character.

    2. Using SetTargetPosition()
    On page 30 of the User's Guide, I show you how to use the MC's SetTargetPosition() and ClearTarget() functions to make the character move.

    With this approach, you'll use A* Pathfinding to determine the waypoints you want the character to move to and call MC.SetTargetPosition(xxx) to have it move along the waypoints. You obviously need to create a component that understands how to use A* Pathfinding's data.


    Advanced Stuff
    Once these approaches make sense, check out this video on using the MC with NPCs. In most cases I'm integrating with Unity Nav Mesh Agent. You can do similar things and replace the "Unity Nav Mesh" specific logic with "A* pathfinding" specific logic.

    If this video confuses you too, just stick with #1 above.

     
  7. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    119
    I've actually got to the first step, I should have specified I want to use root motion or something that looks as good as it. Looks like I wont get around coding something myself.
     
  8. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    81

    Thank you!!
    I think I now have some options that are working pretty nicely now!
     
    Tryz likes this.
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    Correct. I show how to use the MC with Unity's native solution since everyone has access to that.

    There are a lot of path-finding solutions on the Asset Store and you can use any of them with the MC, but you'll have to create the bridge or integration that fits the solution you choose. Fortunately, you should be able to use my documentation, videos, and Unity Nav Mesh code as resources.
     
  10. PiterQ70

    PiterQ70

    Joined:
    Mar 3, 2015
    Posts:
    59
    How can I do this:
    I have custome motion Crawl (just lie down on the ground). I want to break this motion only with input(Y,X axis) and do this motion?
     
  11. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    In the TestUpdate() motion, return "false" when you want to end the motion. So, you can check your input in that function and return "true" or "false" based on the condition you want.

    Please see the Motion Builder's Guide. I talk about TestUpdate() on pages 3 and 17 with an example on page 23.
     
    PiterQ70 likes this.
  12. PiterQ70

    PiterQ70

    Joined:
    Mar 3, 2015
    Posts:
    59
    @Tryz OK I read docs and now I know what is responsible for what :D
    Sorry for take your time to answer questions who was in docs. Thanks
     
    Tryz likes this.
  13. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,818
    @Tryz Are there any plans to expand the climbing functionality so that when free climbing the player can go side to side instead of just up and down? I remember also that you had shown a video at one point of ledge climbing as well. Is that going to be added?

    [EDIT]
    I found the post with the ledge climbing video.

    https://forum.unity.com/threads/motion-controller.229900/page-108#post-3545215

    You had said it was done and would probably be released in July. Whatever happened to this?
     
    Last edited: Nov 2, 2018
  14. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    885
    Contract work happened. :cool: Tim has been pretty swamped the past few months.
     
    Tryz likes this.
  15. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    No plans for that.

    No doubt.

    Unfortunately, @TeagansDad is right. After making the post about the climbing motions I was hit with some contract work that really sucked up all my time. Since I don't make enough money on the Asset Store to pay for my mortgage and college for two kids, I can't turn down work like that.

    I also spent what time I did have working to get support for Unity's Assembly Definition Files out. That was a pretty huge change (and @TeagansDad was a huge factor in getting it done).

    But, in all fairness, I did say I would do the work and give it away for free and it's been several months. So, I'll release what I've done on the Vault and people are free to use it and/or modify it as needed.

    I have tested it some, but not as thoroughly as I would if I were to put it on the Asset Store. Feel free to use it and modify it as needed.
     
  16. paifu

    paifu

    Joined:
    Jul 15, 2012
    Posts:
    20
    Hi I have questions regarding the bow and generally equipping motions.
    (I emailed your my purchases ID, I forgot to do that before)

    I would like to have faster equip motion or even skip them if possible. I modified my animation speed, but I can't go a down a certain speed or the equipping message don't trigger and the weapon isn't equipped.

    I would like also to modify the speed of the aiming draw, to get a to the maximum pull faster.
    I saw that in BasicRangedAttack.cs in the update the filling of the crosshair is based on:
    float lPercent = Mathf.Clamp01((mMotionLayer._AnimatorStateNormalizedTime - 0.7f) / 0.2f);

    Do I have also to modify the animation to pull the draw faster or there is a variable somewhere to regulate this?

    Thanks.
     
  17. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    885
    What's happening here is that the animation event is firing while you're still in the transition from AnyState -- and any animation events that fire during a transition won't get caught. You can try reducing the transition time into the equip animation. If the transition time is 0.15, try dropping it to 0.1 or 0.05. It's short, but it will still blend the animations, unlike if you set the transition time to 0.
     
    Tryz likes this.
  18. paifu

    paifu

    Joined:
    Jul 15, 2012
    Posts:
    20
    Thanks it help a bit, for the second part any idea how I can fasten the aiming draw to maximum pull of the bow?
     
  19. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    You can change the speed of the "Overdraw" state in the animator.

    If you watch the animator when the character is aiming and maximizing the bow, you'll see it's just the "Overdraw" state animation that's playing in the BasicRangedAttack-SM sub-state machine.

    With that, you can click on the "Overdraw" state and change the speed to your liking.



    Increasing the speed will make the maximum pull faster. You can also change the speed of the transition from "Aim Draw" to "Overdraw".

    There's really nothing tricky. It's just normal Unity animator work. :)
     
  20. paifu

    paifu

    Joined:
    Jul 15, 2012
    Posts:
    20
    Thanks, it works perfectly I was searching complex things for nothing. :rolleyes:
     
    Tryz likes this.
  21. paifu

    paifu

    Joined:
    Jul 15, 2012
    Posts:
    20
    Hi, I don't know if it's because of the new Assembly Definition Files or it was already like this before, but I can't use other namespace inside the ootii scripts.
    I know that I would loose compatibility on future ootii updates if I modify directly the ootii scripts but I would prefer to be able to modify them at will for my game.

    If I type using "customnamespace"; on top of an ootii script I got an error: this type or namespace can't be found.

    Only way to use my customs scripts with my customnamespace is to create the cs files inside the ootii folder, it's ok for my own scripts but difficult if I also try to use classes from other plugins.

    Is there a way to modify so the ootii scripts, or the plugin settings so I can use other namespaces?
     
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    This is the way Unity's Assembly Definition Files work; they create segmented code areas (assemblies).

    The easiest solution is just to remove them. To do this, delete all the .asmdef files:
    Assets/ootii/_Demos/ootii.Demos.asmdef
    Assets/ootii/Assets/ootii.asmdef
    Assets/ootii/Editor/ootii.Editor.asmdef


    If you want to keep the benefits of ADFs and access custom namespaces inside my assemblies you need to add your own assembly definition files and allow my assemblies to reference them.

    For example, if you look at the "ootii.Demos" assembly you'll see it references my "ootii" assembly. You would add your references to the "ootii" assembly (and possibly ootii.Editor).



    [EDIT]
    See @TeagansDad 's note two posts below this!
     
    Last edited: Nov 4, 2018
    hopeful likes this.
  23. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    81
    Hey Tim. Quick question.
    Are the "Sensor" and "Memory" functionalities still available in the MC? Were they taken out (or ever added?)?
     
  24. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    885
    @paifu
    IMPORTANT: Deleting the ootii .asmdef files can potentially cause the loss of data on any component that contains a list of classes which don't inherit from UnityEngine.Object. This includes Motions, BodyShapes, BasicAttributes, CameraMotors, ReactorActions, BoneMotors, and others.

    This is because objects are serialized with the assembly qualified name of the class, which will change if you remove the .asmdef. I did build in some tolerance for this scenario, but I cannot promise that no data loss will occur.

    IMO, Unity should have done this from the start to enforce good programming practices. Having all script files in a single .DLL where you can create all manner of circular references is a bad idea all around, IMO.

    Unity is moving towards .asmdef being the standard though. For example, everything that is available through the Package Manager must use assembly definitions.
     
    Tryz likes this.
  25. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    They were never added. I was toying with them, but they were never fully built.
     
  26. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    114

    You might want to look into using Ooti's Reactors instead of modifying the actual core code if you haven't already. You can customize what happens by hooking into events and that way you can do custom code when someone attacks for example.
     
    Tryz likes this.
  27. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    Hey Tim,

    I have a question regarding Simple motion.

    I'm trying something new with my project and figured out using one simple motion with a motion phase X and then having other criteria is great to have one simple motion that can play different animation depending on conditions. Ok, easy stuff so far.

    I would like to know: Is it possible to interrupt that simple motion with itself to not wait the end of the animation and play again the motion?

    Let's take a simple example:

    Let's say I have a simple motion called High Five
    I built a little script to do "Motion Controller Activate Motion with "R Motion Name" and "R Parameter" (sorry, not coding language here ^^)

    It works well. Every time my conditions in my script are true: it plays the High Five motion. But everytime I press the button I have to wait that the animation in the animator is finished to play it again. I would like to sometime be able to say "hey even if this animation is playing around its 60%, go transition it back from the beginning"

    So is there a way to force the animation to play again (transition to itself) with some Motion controller settings/script?

    thanks a lot
     
  28. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,818
    @Tryz There are two things that I'm hoping I can improve through settings somewhere, but I have been unable to find any settings to do the job.

    The first is some sort of camera smoothing/dampening so that the camera isn't following the character like it's attached. When a character goes up and down stairs, for example, the camera jumps up and down with every step. I would like to see the camera a bit more independent so that it doesn't mirror the exact movement of the character and will flow along with the character without the movement jittering for every time the player character steps up or down slightly.

    Second, it's nice that we can now be moving when we are attacking, but that movement is still fixed with regard to the rotational direction of the character. So if a character is not perfectly lined up when I start a chain of attacks, I can't adjust his rotation during the sequence. I have to abort the attack, make a slight adjustment and then try again. But then the enemy may have moved a little so then I'm back to square one again. It would be nice to be able to move while attacking in all directions so that the combat is more fluid.

    Now maybe there's some settings for this, but I couldn't find anything.
     
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    Unfortunately, no.

    A motion (including Simple Motion) can't interrupt itself. The TestUpdate() function that checks if it should run won't run if the motion is currently active.

    In code, you can force the active motion to deactivate with the Motion.Deactivate() function and then you can force it to activate again with MC.Activate(Motion), but it won't do it automatically.
     
  30. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    For this, I use a 3rd object I call the "Camera Anchor". This is a great way to add the smoothness and behavior you're talking about.

    Check out this post on Camera Anchors. I have a component you can use as well.

    I think I understand what you're asking. The rotation comes from the motions on the first layer (Basic Idle, Basic Walk Run Pivot, etc)

    For example, if I check "Rotate With Camera" on Basic Idle and Basic Walk Run Pivot then I can swing and rotate at the same time.

    I can do this in my demo_SSMP by doing the following:
    1. Open demo_SSMP
    2. Setup SSMP on the second layer (index 1 on Packs tab)
    3. Check "Rotate With Camera" on Basic Idle motion
    4. Change Unity Input Source's View Activator to "None".

    So, when I press play moving the mouse rotates the character. Equipping the sword and shield still allows this to happen. Even when I swing the weapon I can move the mouse to rotate the character. That's because the rotation is occurring on the first layer (index 0).
     
    FargleBargle, Weblox and magique like this.
  31. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    Thanks for the answer, I'll see if playing around with Deactivate can do the trick

    Meanwhile I have a problem where I can't wrap my head around.

    I'm using a third party... let's call it weapon manager, it's just something nice that has an inventory solution and manage all weapons feedback, bullets and so on.

    I played with it for some time and am sure I want to use that. But I do want to keep using MC and the motion packs.

    My example here is with a rifle.
    I have MC setup with Shooter motion pack, made all tests with the demo M4, everything is fine.

    My issue is: my other tool has an inventory that will attach a weapon to the character bone of my choice and allow its usability (shooting, particles, collisions and so on).

    Meanwhile, Motion Controller also instantiate the object and attach it to a bone.

    As MC inventory is basic (the component is also named like that, no offense ^^) I'd prefer to use the other inventory solution to attach the object to the bone.

    I can't figure out a solution (I looked at the code) to have MC use a weapon already in the scene and don't manage any instantiation.

    Would there be a solution for that like "Hey MC Shooter motions, the weapon you're going to move around (here I'm speaking about the animations from the motion only, not the muzzle flash, bullet count, damages and so on) is that one here in the scene. Don't equip it, it's there already.

    Any idea?

    Edit: I think my question should be more like: Is there a way to force MC to go to the proper motion phases (L0: 500 // L1: 500) without having to equip an item?
     
    Last edited: Nov 6, 2018
  32. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    It feels like there's a couple of things you're asking...

    1. Can i use a custom gun with the Shooter Motion Pack?
    Yes. However, the gun needs a GunCore (or inherited class that derives from GunCore). If you look in my BasicShooterMotion.cs FindWeapon() function, you'll see that it will ask the IInventorySource for the "Instance" that is the weapon to use (line 515). Then, it grabs the GunCore class (or derived class) from that instance (line 520).

    When the motion shoots, it calls the GunCore's Fire() function where you can do what you want... like trigger your 3rd party gun to fire.

    2. Can I use a different inventory solution instead of your Basic Inventory?
    Yes. I do this with the Inventory Pro Integration. You need to implement the IInventorySource interface for your inventory solution. With it, you'll fill out functions like EquipItem() and GetItemPropertyValue() based on your inventory solution. That second one is used to get the GameObject that is in the instance of your weapon.

    For what you're doing, you just need to figure out if you're using a custom GunCore a custom IInventorySource or both.
     
    Weblox likes this.
  33. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    I was sure I would not word it properly...

    What I was asking was:

    I do not want MC to physically attach a weapon to a bone as I already have a solution for this. I just need to have a way to tell Mc “hey, there is now a gun attached to the hand bone, go in the proper phase mode please and consider the gun to be that object that the other inventory instanced in the scene”

    Also I am not Sure to need the gun core at all if I am already managing this elsewhere that would be expansive for nothing (but I guess the core also set the phases)
     
  34. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    You'll have to force the character into the Stance and Form. Just set the Actor Core directly with ActorCore.SetState("Stance", <value>); etc. That will set the character in the shooter stance without going through my BasicItemEquip motion.

    Then, you use the "FindWeapon" function that I mentioned in my #1 to set the mGunCore property inside the motion. You'll need a GunCore on your custom weapon to set this property.


    This is one of those really custom customizations that you'll just have to follow the logic and try. :)
     
    Necka_ likes this.
  35. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    Thanks a lot for that, I know you can't built the thing for me but I didn't know about setting the Actor Core in that way and I'm making very good progress just with those hints!

    Actually as I like also to have the Equip animation I made a trick around the Basic inventory and my own stuff.

    I keep just one item (for the shooter example only so far) called "Rifle_01" and when my own inventory equips any rifle I modify the "Instanced object" of the basic inventory

    upload_2018-11-7_6-20-29.png

    and then call the Equip motion (and also use the Mount Point code to connect the stuff properly in the right bone - did I said Mount Points is awesome? no, then: Mount points is awesome guys, buy it!)

    I tried first just setting like your example "ActorCore.SetState("Stance", 15); as 15 seems to be the one for Shooter.

    But that didn't do anything.

    Then I saw that there is a "SetCurrentForm", which I've set to 500: then I got the proper animation set

    So I'm wondering about that if this is correct. Because in the animator

    upload_2018-11-7_6-15-28.png

    If I press manually the key "4" the Stance in the Animator changes to 15.

    But if I manually set the actor core state "stance" to 15, it updates it on the Actor Core but not in the animator - is that an issue and if so, what would be the way of changing that? Because typing manually (for testing) 15 in the Animator parameters resets it to 0 straight away (some update calls must force it)

    Also: the Gun Core. I'm quite confused but I don't have any on my custom weapon and that doesn't seem to be a problem. My weapon has its own component that shoots and manage bullets, spread and so on. The gun core is missing but no errors are showing anywhere, so I'd think it's ok on that part.

    But I'll have a look at using (or overriding) the FindWeapon() method
     

    Attached Files:

  36. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    Ok, found why pressing "4" was doing the trick and couldn't manage it via code.

    So I just have to call "Equip Weapon Set" and that's it. No GunCore required, I just have a sample rifle item (which has the already instanciated weapon set at runtime) and a sample equipment set item and that's it, made the trick

    For those interested in how it looks like:

    upload_2018-11-7_16-40-55.png

    Basically, when my inventory detects a Weapon change it sends an event that:
    1-Physically change the weapon by equipping it on the Right Hand bone
    2-Tell Ootii's Mount Points to connect the weapon in the proper position/rotation
    3-Set the field "Weapon Instance" on the basic Inventory of my sample Rifle
    4-Equip the Weapon set from the basic Inventory (I believe it set all the proper motion phase/form and all)

    Then it's all good :)

    thanks again for the hints! it was easier than I expected
     
    Tryz likes this.
  37. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    Sorry for the spam, but I noticed quite a big problem (which isn't related at all with my previous posts)

    I wanted to do a performance check in build mode. that's the first Build I do since the whole Ootii assembly updates (no clue if that could be related, I doubt it)

    My character is running at 1000km/h (you can replace by miles per hour you get the idea) when set to root motion
    In Play mode in the editor I noticed that the speed wasn't consistent depending on the FPS I had (~40/50fps), but I didn't really pay attention.

    In Build mode, I have 300 fps and it's like the character is totally following that speed.

    If I set the walk/run speed to 3/6 it's looking terrible (ice skating) but the speed is normal again.

    Would you have any idea about what could cause that?
     
  38. Bochis

    Bochis

    Joined:
    Jan 2, 2016
    Posts:
    7
    Hey everyone, I just bought the motion controller and sword pack and I have encountered a weird issue while learning to use it. When I equip the sword and shield my character just sinks into the ground up to his chest and cant move. (cool RPG gameplay idea at least, you pick up a cursed sword and you are sucked up by the ground! xD)

    This is also happening in the sword and shield demo without doing anything to it.

    Regular motion controller works perfectly, my character can run, climb, sneak etc. Also using unity 2017.4.2f2 currently and I am not using any special inventory assets.

    Any ideas what could cause this strange behavior?
     
  39. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    139
    Did you download and install the Mixamo animations correctly?
     
    Tryz likes this.
  40. Bochis

    Bochis

    Joined:
    Jan 2, 2016
    Posts:
    7
    Yes, to my knowledge I followed the instructions to the letter. Followed manual instructions and double checked with the video. My folder contents and file names look exactly like in the video.

    Forgot to mention that there are no errors during play, and the demo character equips his shield when he sinks into the ground.
     
    Last edited: Nov 7, 2018
  41. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    432
    On top of having imported the proper animations from Mixamo, you also need to extract the Meta files that are zipped in the motion pack folder
    Check out the manual, you might have missed that part
     
    Tryz likes this.
  42. Bochis

    Bochis

    Joined:
    Jan 2, 2016
    Posts:
    7
    Ok I apparently solved the issue by deleting everything and reimporting the animations and meta files. Must've failed somewhere with the import, or clicked on unity by accident and generated meta files and then not properly overwritten them.

    Oh well, problem solved. Time to fully enjoy this amazing asset! Thanks for your help Keith :)
     
    Tryz, hopeful and KeithBrown like this.
  43. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    You can definitely get different FPS in editor vs. build. Sometimes if you hide the Scene editor window you'll see the frame rate pick up.

    As for the associated root motion, I'm guessing that Unity is slicing the animation distance based on the frame rate. It should all be about the same, but I could see there being some differences especially in the editor with an animator window open. In an actual build I would expect the root-motion resulting distance to be exactly the same no matter the frame-rate. I just take what I'm given by Unity and apply it.

    Once you manually set the walk/run speed, I totally ignore root-motion and you will get ice skating if the speed you set isn't exactly what the root-motion would produce. Which makes sense since the animation still plays at the same rate... the movement is just disconnect from the animation when you manually set the values.
     
  44. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    Hi there,

    I'm trying to setup motion controller with the shooter pack to be used in a turn based game. So the input would be given by the navmesh to move and the keyboard to all the other commands. I'm going a bit crazy with the navmesh input/ navmesh driver and couple both with the keyboard commands to acces to the shooter stuff.

    Could you give me a hint to do that? I've watched again and again the navmesh tutorials, but i'm missing something somewhere.

    Thanks a lot!
     
  45. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    I'm sorry, i've found now the allow user input check.

    Anyway if you have any suggestion, please go ahead!

    Thanks a lot!
     
    Tryz likes this.
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    Check out thos video:


    There's a Motion Controller playlist with a lot of videos and one on NPC movement. It doesn't use the Shooter Motion Pack, but it will work.

    I’m travelling and internet is spotty.
     
    Danirey and KeithBrown like this.
  47. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    81
    How would I get a character to inherit the speed of a moving object?
    Let's say I have a character riding one of those flying speeder bikes in Star Wars.
    If it gets blown up, the character would fall but still continue moving forward, because of the initial velocity.

    I have a motion where the character is able to turn such a function on and off (perhaps more like the Sparrow bike in Destiny, or let's just say Iron man's ability to fly when he chooses). When activated, the character just begins flying forward. However, when deactivated, he just drops vertically to the ground, regardless of any forward movement. This was intermittent, sometimes it worked, sometimes not.

    To fix this, I used the AddForce function on Deactivate(), and it does solve my problem of inheriting the velocity. But say if I decide to activate the motion again in the air, before touching the ground again. Now, for some strange reason, I can't move my character anymore. To give a bit more info, I'm actually using the transform when this character is in his vehicle mode. It's just constantly moving forward and turning based on a LookAt fucntion that points to a target game object (parented under the player). As I couldn't figure out how to keep those nice collisions that the AC gives me, I create a rigidbody when activated, and as far as I can tell, it gives me a pretty similar result.

    I'm fairly satisfied with most of what I have, but my question is, what do I have to do to "reset" the velocity when the motion is turned on again.

    Here's what I have on Activate():


    Code (CSharp):
    1. //This is my unsuccessful attempt to reset the accumulated velocity
    2.             mActorController.SetVelocity(new Vector3(0,0,0));
    3.  
    4.             // Ensure AC gravity is disabled:
    5.             mIsGravityEnabled = mActorController.IsGravityEnabled;
    6.             mActorController.IsGravityEnabled = false;
    7.  
    8.             mIsOrientationEnabled = mActorController.OrientToGround;
    9.             mActorController.OrientToGround = false;
    10.  
    11.             mActorController.FixGroundPenetration = false;
    12.  
    13.             // Flip the rotation order
    14.             mActorController.InvertRotationOrder = true;
    15.  
    16.             //Enable Use Transform for Flight
    17.             mActorController._UseTransformPosition = true;
    18.             mActorController._UseTransformRotation = true;
    19.  
    20.             //Add and Enable Rigidbody
    21.             rb = mActorController.gameObject.AddComponent<Rigidbody>();
    22.             rb.isKinematic = false;
    23.             rb.useGravity = false;
    24.             rb.freezeRotation = true;
    25.  
    And here's what I have on Deactivate():

    Code (CSharp):
    1. // Re-enable gravity
    2.             mActorController.InvertRotationOrder = false;
    3.             mActorController.IsGravityEnabled = mIsGravityEnabled;
    4.             mActorController.OrientToGround = mIsOrientationEnabled;
    5.             mActorController.FixGroundPenetration = true;
    6.  
    7. //Disable Use Transform for Ground Movement
    8.             mActorController._UseTransformPosition = false;
    9.             mActorController._UseTransformRotation = false;
    10.  
    11.             //Destroy/Disable Rigidbody
    12.             rb.isKinematic = true;
    13.             rb.useGravity = true;
    14.             Rigidbody.Destroy(mActorController.GetComponent<Rigidbody>());
    15.  
    16. //This is used to inherit the flying velocity, and pass it off to the Actor Controller:
    17.             mActorController.AddForce((TargetDistance), .25f);
    Again, Deactivate seems to be working fine, as far as I can tell. It's only when I activate it again in mid air, that I'm not able to control the character anymore.

    Thanks in advance for any tips or pointers. Tim, I hope you're enjoying your travel, or vacation (if that's the case).


    EDIT: I actually have a way of moving the character on it's vehicle totally through an outside script too, and probably wouldn't mind doing it that way either. My question though, is how do I pass on the velocity/momentum of the original movement to the Actor Controller/Motion Controller?
     
    Last edited: Nov 14, 2018
  48. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    191
    anyone know how to turn on a Motion in a given layer from script?
    I cant get "ActivateMotion()" to do anything...
     
  49. Arcanebits

    Arcanebits

    Joined:
    Dec 18, 2013
    Posts:
    66
    Hi, I Guys, im in the need of some advice

    1- Does the assets break somehow Playmaker? I cant even make a FSM so simple that follows the player, an then when in contact with it, reports the GameObject in question... Thats my basic "everything works test".

    2- If I get a Drone or some Character with just ONE animation, whats the simpler way to make it follow the character and be damaged (by player sword for instance), and when in contact the player, RESTART the Scene. In other words, whats the minimun requeriments for that in the GameObject.

    3- Is there a way to have som "damage on contact" with the player? A la Arcade games?

    4- May sound stupid, but the colliders of the swords are calculated at the start? since there is no box collider or some stuff like that.

    Cheers!
    Aldo
     
  50. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    139
    You did not post any code but here is some code to activate a jump motion that uses ActivateMotion.

    Code (CSharp):
    1. using UnityEngine;
    2. using com.ootii.Actors.AnimationControllers;
    3. public class dev_Simple_Code : MonoBehaviour
    4. {
    5.      protected MotionController mMotionController = null;
    6.  
    7.      void Start()
    8.      {
    9.          mMotionController = gameObject.GetComponent<MotionController>();
    10.      }
    11.  
    12.      void Update()
    13.      {
    14.          if (UnityEngine.Input.GetKeyDown(KeyCode.Space))
    15.          {
    16.              MotionControllerMotion lMotion = mMotionController.GetMotion(0, "Jump");
    17.              mMotionController.ActivateMotion(lMotion);
    18.          }
    19.      }
    20. }
    If you just search the code for ActivateMotion you will find around 90 instances of it being used in the ootii code base. That assumes you have all of the motion packs installed.
     
    Tryz likes this.
unityunity