Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Corgi Engine - Complete 2D/2.5D Platformer [new v8.0 : advanced damage system]

Discussion in 'Assets and Asset Store' started by reuno, Dec 18, 2014.

  1. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @krisss666 > The space-corgi-spritesheet example doesn't have a model node, it simply flips the sprite (using the sprite renderer's flipX), so any child object will keep facing its initial orientation. You need a model node for that, like on the RetroCorgi example.
     
  2. krisss666

    krisss666

    Joined:
    Feb 14, 2014
    Posts:
    21
    ok that make sense now, my bad i picked the wrong base to make my test ^^
     
    reuno likes this.
  3. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Question regarding MMFeedbacks on the UAS. is there anything (besides the Nice Vibrations bonus) that would warrant a separate purchase, since I have both Corgi and Top-Down? Thanks!
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @christougher > No, there isn't.
    The only benefit would be the one click install button for it.
    Aside from that, it's the exact same content as the one you get with Corgi or TDE, plus NV as you noticed :)
     
  5. SRx734

    SRx734

    Joined:
    Sep 4, 2018
    Posts:
    8
    Hi, reuno! I'm having trouble with running jumping. Now if the character starts jumping in running state while holding the run button, it can keep running speed midair, but if I release the run button in air and then try to press it again, its speed drops to walk speed and cannot go back to running speed anymore.
    My concerns are: for my game, it is natural to jump further if the characterstart jumping at higher horizontal speed, as long as the character is still facing the start jump direction it can keep this speed, but if the character flip it loses that momentum and drops to walk speed, and run button, pressed or released, shouldn't have any influence on character speed if the character is in air. Are there any options I can tweak to achieve this behaviour? If not, can you give me some hints on modifying the code?
     
  6. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @SRx734 > No, in the engine at the moment you can only run while grounded, pressing run again in the air will not let you run. The easiest way to change that would be to extend CharacterRun to implement different rules in its RunStart method.
     
  7. SRx734

    SRx734

    Joined:
    Sep 4, 2018
    Posts:
    8
    Yes but I don't want to run in the air, I only want the character to keep run speed in the air as long as it doesn't flip, if it starts jumping while running. Right now the engine only keeps run speed if holding run button all along, and the speed won't drop if the character flip in the air.
     
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @SRx734 > Indeed, right now that's how it works. But if you extend CharacterRun, you'll be able to implement your own specific rules for that.
     
  9. andrin2020

    andrin2020

    Joined:
    Mar 9, 2014
    Posts:
    29
    I think you are failing to understand here is that the "bug" which you posted here is not actually a bug. This is not a game that has been released for playing this is an engine to create games. While the AI on the enemy in question may not be set up the way you would have done it, it is possible, and quite simple, to correct if you are willing to do so. A bug would be an error in the coding of the AI system scripts preventing expected behavior not how they were applied in a situation.

    Reuno has been nothing but amazingly helpful to me and to the overwhelming majority of users of his engines. I can not understand why you are so rude to him and refuse to accept his help.
     
    javi_unity402 likes this.
  10. AltIvan

    AltIvan

    Joined:
    Aug 3, 2013
    Posts:
    12
    Last edited: Dec 18, 2020
  11. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @AltIvan > At this point I'm not sure if you're serious or not.
    You realize it's an engine, not a game? Complaining you can "fly" using that sword and a dash is as weird as saying you can go through walls in the URP demo scene by flying through them in the editor. You can limit dashes if you want (or disable them, or change their force, or, or...) You can define the force applied on that sword's use. And yes, of course you can fix that pushable without a line of code. You can also prevent a corpse from firing, and all that without a line of code.

    So once more, these are not bugs. That's not what bugs are. Bugs are logic issues, or things that would prevent you from doing what you want. Here the only thing preventing you from doing what you want seems to be yourself.

    And if you want to report bugs - even if you honestly don't know what is or isn't a bug, I've told you how to do so, you know the process. It'd also help to say what you changed in the levels. For example, your "shooting through a teleporter bug" can't happen in the default conditions. I think I know what you changed, but it'd help to have context info. A video doesn't provide that. Thankfully, next to the contact form, you'll find a list of base info you can provide if you want your "bugs" fixed, or simply explanations on how to do things.

    Now I'll be very clear : I won't tolerate that attitude anymore. You're aggressive and, I think, just trolling now. If you actually want my help, please use the support form, like absolutely everybody else. If you don't want my help, please stop posting here.
     
    Last edited: Dec 18, 2020
    kdbguy, javi_unity402 and Boom_Shaka like this.
  12. javi_unity402

    javi_unity402

    Joined:
    Nov 29, 2018
    Posts:
    33
  13. xagarth

    xagarth

    Joined:
    Sep 7, 2016
    Posts:
    17
    Hey @reuno

    I hope you've been good.
    I was trying to find a way to do rewind, re-simulate of my character, but it seems pretty hard as there's much stuff handled automatically on update.

    I've been able to extract those and trigger manually, but it seems that running EveryFrame() 10+ times per frame on CorgiController just kills the performance completely.
    Maybe there's a better way to do rewind/re-simulate the controller based on input, gravity, etc, and i'm missing it?
    I do believe the controller is deterministic, right?

    Bests,
    X
     
  14. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @xagarth > ah, indeed, running the controller's routine 10+ times every frame is bound to be taxing.
    Right now there's no built-in solution for that, and I can't think of a simple one that wouldn't cost a lot.
    I guess the way I'd do it is simply get rid of the simulation, as it's been paid for already. Storing positions and states would be way cheaper, perfectly accurate, and easy to replay.
     
    xagarth likes this.
  15. mike000mike

    mike000mike

    Joined:
    Oct 25, 2017
    Posts:
    8
    Corgi Engine FPS 2.png
    Hi,@reuno, I have found that if uncheck all enemies "Draw Raycasts Gizmos", FPS will up to 90 :cool:
     
    Boom_Shaka and reuno like this.
  16. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @mike000mike > Ah yes, on lower end computers, drawing gizmos in editor comes at a cost. Disabling them will increase performance.
     
  17. GamerNZnick

    GamerNZnick

    Joined:
    Jan 9, 2019
    Posts:
    6
    Hi,@reuno, I'm using Unity 2020.1.11f1 and I've created a URP base project with just a plane in it nothing else. The camera is setup as a URP camera. However as soon as import the corgi package this changes to a standard camera.

    I cam across this as I was planning on creating a 2.d game, but the materials keep going transparent once I load Corgi or if Corgi is installed. They use a custom shader to create outline and a cartoon feel. By transparent if I select the model in the scene all I get in the editor is an outline regardless of whether I have 3d or wireframe selected in the view.

    If I stop using the custom shader and try the universal render lit shader, then the materials are just pink.

    I'm sure I'm not the first to experience so hopefully you can get a quick answer,
     
  18. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @GamerNZnick > No, I don't think anyone's reported such an issue.
    Are you sure you did setup URP correctly though? Are your rendering assets properly setup?
    My guess here would be you're trying to use URP materials in SRP.
     
  19. GamerNZnick

    GamerNZnick

    Joined:
    Jan 9, 2019
    Posts:
    6
    thank for the quick response.

    I created a URP project from Unity Hub and literally all I did was add a plane game object with a material on it. The camera was the default camera was created by the project creation. Which was a URP camera I.e I can change its type and has rendering pipeline options. There are no other packages or assets loaded other the demo create when you create a URP project.

    The only materials I’ve used are from the demo that’s created when you create a URP project.

    Once I installed Corgi the Camera changed to a standard one, ie I have no rendering options, wasn’t able to change its type etc. If I create a new camera I’m not able to create a URP one.

    Then everything starts to get a bit funky with the shaders. I have another project which is a URP which I have my custom shaders all working on. When I install Corgi I do get a message regarding dependencies and project settings being overwritten. Do you think this might be the issue.

    I’m using unity version 2020.1.11f1. Do you think this could be an issue.

    Cheers
     
  20. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @GamerNZnick > As I said, I don't think you did set your render pipeline setting correctly.
    I doubt it's related to your Unity version (although it could be).

    Here are the simple steps I just did as a test, it seems to work just fine :
    - install 2020.1.17f1
    - create a new project (URP), import Corgi Engine v6.6 into it, from the package manager window
    - in project settings > graphics, set a URP asset in the Scriptable Render Pipeline Settings slot. I've used the HighQuality one that comes by default with a new URP project, but you could of course create your own.
     
  21. FNRocha

    FNRocha

    Joined:
    May 30, 2015
    Posts:
    9
    Hi everyone, I hope I am posting in the right thread. This is actually my first time posting in any unity forum.
    So, I am trying to develop a game with movement like megaman X4 games (example video:
    ). I have managed to create a class that inherits the dash ability so the character does a proportional dash. Now I have two questions:

    1- Is there a way to create a jump class mechanic using constant velocity instead of the force? from the video (around 00:04 to 00:10 in video) you can see that in this game the jump mechanic has something of a constant velocity, allowing for very short hops or high jumps. I couldn't find a method SetVelocity in the documentation. In previous projects I have implemented this kind of jumping, but I don't know how to do this in the corgi engine way.

    2- Is there any suggestion about implementing the dash jump shown in the video? I am thinking of creating a custom Jump Ability Class that would read the dash force from the Dash Ability Class and apply it, but I am confused if I would need to create a new dashingjump state, that seems complicated since CharacterState is an enum.
    Thanks in advance!
     
  22. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @FNRocha > Setting a constant force will in turn give you a constant velocity.
    And I may be mistaken but from that video it looks like this dash is just an initial burst and then a speed multiplier.
    As for adding a new state, I don't think you'd need one (unless you plan on also having another dash, but if you need to, you can directly add it to the enum, as unfortunately C# doesn't let you extend enums.
     
    FNRocha likes this.
  23. FNRocha

    FNRocha

    Joined:
    May 30, 2015
    Posts:
    9
    OK I am officially a fool. I was so caught up with my other last codes that I simply forgot to think about the basic physics.
    Also I just realized that the jetpack class can be used to obtain this jump more easily.
    thanks!
     
    reuno likes this.
  24. matttardiff

    matttardiff

    Joined:
    Feb 27, 2018
    Posts:
    30
    @reuno I just a support ticket but I'm just placing the same question here in case anyone else has had the same problem and found a solution.

    I'm using the UICamera that comes with the Corgi Engine. Everything works great but I have one problem, click through the UI. I do not offer keyboard support and added a script I found online that hides and locks the cursor. The problem is that if I click on the mouse, it deselects the pause button and I can't get back to it. That is the only thing keeping A Crooked Heart from getting approval to the Steam Store. I understand that this may have nothing to do with the Corgi Engine. If so, just let me know and I'll continue looking for a solution elsewhere. Thanks for you help.
     
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
  26. matttardiff

    matttardiff

    Joined:
    Feb 27, 2018
    Posts:
    30
    Thanks @reuno That's exactly what I needed to know.

    I found this somewhere and it works like a charm.
    I slapped it onto a GameObject and the rest is wonderful excitement.

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.EventSystems;
    6. public class KillTheMouse : MonoBehaviour
    7. {
    8.     GameObject lastselect;
    9.     void Start()
    10.     {
    11.         lastselect = new GameObject();
    12.     }
    13.     void Update()
    14.     {
    15.         if (EventSystem.current.currentSelectedGameObject == null)
    16.         {
    17.             EventSystem.current.SetSelectedGameObject(lastselect);
    18.         }
    19.         else
    20.         {
    21.             lastselect = EventSystem.current.currentSelectedGameObject;
    22.         }
    23.     }
    24. }
     
    Last edited: Dec 24, 2020
    Boom_Shaka and reuno like this.
  27. Razeta

    Razeta

    Joined:
    Jun 27, 2018
    Posts:
    3
    Hello, I bought the Corgi 2d on the dec sale. But I been having troubles trying to open the pause menu in the corgi 3d demo scenes. In the 2d scene works great, but in the 3d scenes I press the esc button and it doesn't work. Anyone has this issue and how to fix it? I seen the videos but no answers there.
     
  28. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    I love the engine, But I am having a problem. For some reason, the engine will not allow me to change the animation controller, I can't drag it in and it is not recognized in the dropdown. The controller was created by the Hippo Character Editor. What am I doing wrong?
     
  29. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @idoltap > The engine can't prevent you from changing an animation controller, that's on Unity's end. And if you can't drag it in, that's probably because it's not the correct type. Hard to tell without any info though. If the issue persists, please don't hesitate to use the support form (https://corgi-engine.moremountains.com/corgi-engine-contact) and provide me with more details, I'll be happy to help you with this.

    @Razeta > Unless I'm mistaken I answered you via email this morning already. If not, your Character is probably just missing a CharacterPause component, adding one should solve the problem.
     
  30. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    this is a known issue with the Hippo Editor: https://discord.com/channels/564425940650819586/579025349115904000
     
    reuno likes this.
  31. MaKuZ

    MaKuZ

    Joined:
    Jan 1, 2018
    Posts:
    5
    Hi @reuno, I was trying to understand the very basics of the movement, I'm not a programmer im an artist, trying to make a shooter game, I did the animation in unity with skeleton and ik, my end goal is a movement like bombastic brothers, they made those animations in Spine, in-game when the character aim to something they move their upper body (just like the hunt demo) and flip when the mouse cursor goes to another side, the problem is now that I have no clue how to achieve that in corgi engine, neither I know how to replace those weapons on current body layer( it should always spawn under the player right/left hand, that spine example of yours do have a similar thing but it is backed, unity 2d bone animation seems only one sprite), I tried almost all the things but no result, I'm a noob, maybe I'm missing some very simple thing, forgive my ignorance, is there any way I can achieve something similar to this, im attaching a video of the game. please help.

     
  32. Boom_Shaka

    Boom_Shaka

    Joined:
    Aug 31, 2017
    Posts:
    141
    It's hard to say from the video, but if you're an artist, the easiest approach would probably be to attach your arm and/or hands to the weapon as a single sprite like the Mad Scientist character in this set: https://craftpix.net/product/mad-scientist-2d-game-kit/

    The body/legs/head are animated separately - all you have to do is set your pivot point so your weapon rotates up/down correctly. Not sure about IK, though...I've only done it with 3d characters. You could do it manually: create "look up"/"look down" animations and use your weapon aim angle parameter to trigger them.

    Your best bet would be to google tutorials on Unity animation/animators - what you're asking isn't related to the engine.
     
  33. MaKuZ

    MaKuZ

    Joined:
    Jan 1, 2018
    Posts:
    5
    thank you very much for the reply, yes, that's indeed a good option, but I'm making a bone animation with ik, here is a better example from spine, this is the exact process that bombastic brothers used.

    Spineboy example (esotericsoftware.com)
    (aim section)

    i don't know how to implement this in corgi engine.
     
  34. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @MaKuZ > As @Boom_Shaka said, this isn't related to the engine (the engine doesn't do any animation, Unity does. The engine just sends and updates animation parameters). In this case you'd need to probably build a custom character rig (weapon attachment and all) that lets you animate it however you want, then have the engine spawn your weapon normally, with probably extra dedicated classes on it to handle IK hands positions.

    As far as the spawning of the weapon goes, it wouldn't require anything special. If you look at the RetroAI demo, at the start of it you can pick a machine gun, it rotates where you aim, just like in your example. What'd be missing is the animation layer on top of that. With spine that'd be relatively easy to implement, but it's just Spine, nothing on the engine's side.
     
    MaKuZ likes this.
  35. MaKuZ

    MaKuZ

    Joined:
    Jan 1, 2018
    Posts:
    5
    thank you, sure, I did till the animation part with my custom rigged character, I know how to replace the corgi characters with mine, so the player is on the platform now running and jumping even i made a custom weapon that also attached (unfortunately its top of my character layer), that weapon is also rotating ( i changed the weapon aim script's control parameter to the mouse, though the character is not flipping based on my mouse position ) i attached the weapon on my IK hand(from the weapon handle script). but the bones ain't following the 360 aimings like the example of hunt (red character, with ik pass on), just the weapon is rotating from the pivot (this is ok with any pixel or simple character with simple to no hands, my character is like bombastic brothers, a bit detailed). I don't know, sorry maybe my lack of knowledge makes it harder for me, maybe i should try spine bone animation instead of unity 2d bone animation.
     
  36. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @MaKuZ > If you've got the weapon rotating, congrats, you're done with the engine part.
    The rest is "just" animation/IK setup. Doesn't mean it's trivial, it can get quite complex.
    What I'd recommend is to get familiar with your IK system of choice (whether it's unity 2D or spine), learn how it works, maybe do a few tutorials to get the basics right, then setup a test character and have it move how you want it to.
     
    MaKuZ likes this.
  37. hotpeperoncino

    hotpeperoncino

    Joined:
    Apr 11, 2019
    Posts:
    18
    Hi, I'm newbie. I want to use 3D humanoid character, I could use the character in your 2.5d demo, but its foot does not touch on slope, it looks lacking IK. I tried to use an very simple IK, but i could not succeed in applying it.
    If you have an example to use foot IK in 2.5D scene with corgi engine, please teach the material or key point or URL . Thank you.
     
  38. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @hotpeperoncino > As I was saying in the posts right above yours, the engine doesn't do animation, Unity does. So you could setup feet IK like you would in any other Unity project. A simple way to do it would be to have a script hold references to both feet IK targets, raycast downwards from the waist, find hit points, and move the targets there. You can learn more about IK in Unity at https://docs.unity3d.com/Manual/InverseKinematics.html
     
  39. LaurieCF

    LaurieCF

    Joined:
    Jul 8, 2013
    Posts:
    10
    Hi Reuno,
    Thanks for your recent e-mail support. Asking this question here so future users might find it, since this is something you seem to be asked about periodically :) - using the weapons system to create a 'charge shot' (as in Megaman, for example).
    Looking at your earlier answers around this, I can see you've pointed users to the very helpful 'Delay Before Use' variable. This is a great start for what I'm looking for, as I need to hold the button down for the duration of the delay, and letting go before this cancels the 'charge'.
    I was wondering how you would advise setting it up so that once the shot is 'charged' it is not fired until the player lets go of the shoot button.
    I'm unsure what would be the best way to go about, but I can see a few functions in Weapon.cs, which seems like the area I would need look at.

    Many thanks in advance!
     
    Last edited: Jan 1, 2021
  40. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @LaurieCF > Right now there is no such feature, what I'd suggest would be to override the Weapon class, and add extra checks to its CaseWeaponDelayBeforeUse. Right now it just looks at elapsed time to see if it should proceed, you'd want to add an input condition.
     
  41. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @AltIvan > No, I didn't do anything. I don't care about your review (let's be real, nobody does), and didn't "get it deleted" (feel free to contact Unity to confirm that, if you've got time to spare). And please stop with the baseless accusations and insults, and maybe just move on with your life.
     
  42. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    75
    Hi Reuno,

    I'm using Unity 2020.2.1f1 and I'm using v6.6 of the engine (according to the package manager) however, I am missing the automovement ability and demo scene. I've seen the comment on the FAQ, and I believe this should be working in this version of Unity.

    Edit: Nevermind, I got it working by redownloading the package in an older version of unity. It seems to be a package manager issue.
     
    Last edited: Jan 4, 2021
  43. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @neapolitanstudios > I'm glad you figured it out, thanks for letting me know. And yes, 2020.2 is unfortunately packed with bugs at the moment, the package manager especially is a complete mess :( Best to stay on more stable versions for now - I'd recommend the latest 2019.4.x.
     
  44. FNRocha

    FNRocha

    Joined:
    May 30, 2015
    Posts:
    9
    Hi, I am having some issues creating a MeleeWeapon, I started following the tutorial in this link : https://corgi-engine-docs.moremountains.com/weapons.html#weapon-laser-sight

    Goal:
    -Create a melee attack that prevents any kind of movement during the attack animation (jumping, crouching, walking...)

    Issue:
    1- It is also possible to jump, dash and perform other actions during this animation.
    (The sliding problem is already fixed by turning off "TimeBetweenUses".)



    My solution was to use an animation behaviour, like the following:
    /----------------------------------------------------------------------------------------------------------------/
    /----------------------------------------------------------------------------------------------------------------/
    public class Custom_StopMoving : StateMachineBehaviour
    {
    protected Character _character;

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    _character = animator.GetComponentInParent<Character>();
    _character.Freeze();
    }

    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    _character.UnFreeze();
    }
    /----------------------------------------------------------------------------------------------------------------/
    /----------------------------------------------------------------------------------------------------------------/

    But I am getting this error:
    " The type or namespace name 'Character' could not be found (are you missing a using directive or an assembly reference?)"

    The error seems to be referring to this line "protected Character _character;".

    Should I be using the Freeze() Method for this problem?
    How should I reference the character script?
    Does anyone have any suggestions?
     
    Last edited: Jan 5, 2021
  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @FNRocha > Prevent Movement only has an impact on the CharacterHorizontalMovement ability, it prevents that movement, it doesn't prevent other abilities from being triggered, and these abilities may well have an impact on movement themselves.That's not only while the button is held though (at least not if you setup your weapon correctly for that goal). Hard to tell what's wrong in your case just from a video, but I'd recommend looking at the RetroComboSword weapon (or its parts, the combo doesn't matter in that context), it does prevent movement as expected, even if you just tap it.

    As for your second question, as your error suggests, did you add the using directive to use the CorgiEngine namespace in your new class? Usually in most IDEs you can just right click on that line (or on Character) and it'll do it for you.
     
    FNRocha likes this.
  46. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    75
    Thanks!
    Another question. I've been playing with the automovement scripts, and so far it's amazing. Everything as working as I require almost out of the box. My only issue is that I can't find where to disable the horizontal movement (in the demo scene, you can still control the player using "a" and "d"). Disabling the horizontal movement script prevents automovement and crouching. I tried removing the keybinds from the input settings, but there is still some connection occuring. Did you have any ideas? Thanks!
     
  47. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914
    @neapolitanstudios > that's not a feature at the moment, it's something you'd have to implement, but I can add it to the todo list if you'd like.
     
    javi_unity402 likes this.
  48. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    75
    Thanks, that would definitely be useful! In the meantime I’ll keep digging around in the code and see if I can prevent movement somehow.
     
    reuno likes this.
  49. javi_unity402

    javi_unity402

    Joined:
    Nov 29, 2018
    Posts:
    33
    @neapolitanstudios Hope this helps in some way

    I also freeze character after shooting a ranged weapon.

    I get it with a combination of this:

    1.- Weapon -> Movement -> Modify Movement While Attacking ( 0 multiplier) + Prevent Horizontal Movement While in Use.

    2.- Disable Jump while weapon in use with this script (Character Ability) (excuse additional commented lines).

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using MoreMountains.Tools;
    4.  
    5. namespace MoreMountains.CorgiEngine // you might want to use your own namespace here
    6. {
    7.     /// <summary>
    8.     /// TODO_DESCRIPTION
    9.     /// </summary>
    10.     [AddComponentMenu("Corgi Engine/Character/Abilities/Character Jump Prevent")]
    11.     public class CharacterJumpPrevent : CharacterAbility
    12.     {
    13.         /// This method is only used to display a helpbox text
    14.         /// at the beginning of the ability's inspector
    15.         public override string HelpBoxText() { return "Character can't jump after shooting"; }
    16.  
    17.         [Header("TODO_HEADER")]
    18.         /// declare your parameters here
    19.  
    20.         protected Weapon _weapon;
    21.  
    22.         /// <summary>
    23.         /// Here you should initialize our parameters
    24.         /// </summary>
    25.         protected override void Initialization()
    26.         {
    27.             base.Initialization();
    28.         }
    29.  
    30.         /// <summary>
    31.         /// Every frame, we check if we're crouched and if we still should be
    32.         /// </summary>
    33.         public override void ProcessAbility()
    34.         {
    35.             base.ProcessAbility();
    36.             ExitDisableJumpShooting();
    37.             DisableJumpShooting();
    38.         }
    39.  
    40.         /// <summary>
    41.         /// Called at the start of the ability's cycle, this is where you'll check for input
    42.         /// </summary>
    43.         protected override void HandleInput()
    44.         {
    45.  
    46.         }
    47.  
    48.         /// <summary>
    49.         /// If we're pressing up, we check for a few conditions to see if we can perform our action
    50.         /// </summary>
    51.         protected virtual void DisableJumpShooting()
    52.         {
    53.             // if weapon is reloading after shooting
    54.             if (_character.GetComponent<CharacterHandleWeapon>().CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses)
    55.             {
    56.                 // if jump ability is already disabled, we do nothing
    57.                 if(!_character.GetComponent<CharacterJump>().AbilityPermitted)
    58.                 {
    59.                     return;
    60.                 }
    61.                 // disable jumping ability
    62.                 _character.GetComponent<CharacterJump>().AbilityPermitted = false;
    63.             }
    64.         }
    65.  
    66.         protected virtual void ExitDisableJumpShooting()
    67.         {
    68.             Debug.Log(_character.GetComponent<CharacterHandleWeapon>().CurrentWeapon.WeaponID);
    69.          
    70.             if ((_character.GetComponent<CharacterHandleWeapon>().CurrentWeapon.WeaponState.CurrentState != Weapon.WeaponStates.WeaponDelayBetweenUses)
    71.                 || !_character.GetComponent<CharacterHandleWeapon>().CurrentWeapon)
    72.             {
    73.                 if(_character.GetComponent<CharacterJump>().AbilityPermitted)
    74.                 {
    75.                     return;
    76.                 }
    77.                 // enable jumping abitily
    78.                 _character.GetComponent<CharacterJump>().AbilityPermitted = true;
    79.             }
    80.         }
    81.  
    82.         /// <summary>
    83.         /// Adds required animator parameters to the animator parameters list if they exist
    84.         /// </summary>
    85.         protected override void InitializeAnimatorParameters()
    86.         {
    87.             //RegisterAnimatorParameter ("TODO_ANIMATOR_PARAMETER_NAME", AnimatorControllerParameterType.Bool);
    88.             //RegisterAnimatorParameter (_headUpAnimationParameterName, AnimatorControllerParameterType.Bool, out _headUpAnimationParameter);
    89.         }
    90.         /// <summary>
    91.         /// At the end of the ability's cycle,
    92.         /// we send our current crouching and crawling states to the animator
    93.         /// </summary>
    94.         public override void UpdateAnimator()
    95.         {
    96.             //MMAnimatorExtensions.UpdateAnimatorBool(_animator, _headUpAnimationParameter, IsHeadUp, _character._animatorParameters);
    97.             //MMAnimatorExtensions.UpdateAnimatorBool(_animator, _facingRightAnimationParameter, IsFacingRight, _animatorParameters);
    98.         }
    99.     }
    100. }
    @reuno +1 to add some extra features to Weapon -> Movement

    *Edit typo
     
    Boom_Shaka and reuno like this.
  50. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,914