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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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,870
    @NAiLz > What's not working with the WeaponAim script?
     
  2. Beldrama

    Beldrama

    Joined:
    Mar 14, 2018
    Posts:
    6
    Thank you for your answer :)

    I just noticed the Owner variable in the Weapon class. Exactly what I was looking for ^^

    Thank you!
     
    reuno likes this.
  3. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Hello again,
    i have an enemy in my scene. When he is killed he doesn't respawn, see attachment.
     

    Attached Files:

    • 12.png
      12.png
      File size:
      99.6 KB
      Views:
      904
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @knuppel > I can't magically guess what you setup wrong, especially with that little info :)
    Look at the documentation, it's explained in details.
    If that doesn't cut it, look at the example scenes, look how it's setup there, and compare with your setup.
    If that still doesn't cut it, send me more details on the support email, thanks!
     
  5. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Well, i just copied a robot from another scene, the robot has a AutoRespwan script added. I want to respawn everytime the enemy is killed. Which further information do you need?
     
  6. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @knuppel > Does the problem happen in the other scene? Have you tried reading the doc? Have you tried comparing with the other scene? Doesn't that solve the problem? Again, please use the support email if that doesn't, thanks!
     
  7. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    Good news everyone, I've just submitted v4.5 of the Corgi Engine to the Asset Store.
    As usual, it fixes all known issues so far, and introduces two new features : entry points, to link levels together via certain entry or exit doors/gates, and character selection.

    Here are the full release notes :
    - Adds a new "Entry Points" mechanism. You can now easily define multiple entry points for a scene, and link scenes together by specifying which point you want to enter the target scene at. Long story short, it's Metroid.
    - Adds two new demo scenes to showcase the entry points system, MultipleRooms 1 and 2. They show how to create rooms inside a single scene, and how to link multiple scenes together with corresponding entry/exit points.
    - Adds character selection. You can now easily create a character selection scene (or change character between levels, that kind of stuff).
    - Adds a new demo scene : RetroAdventureCharacterSelection, that allows you to select one character out of four, and get to play him in all the Retro Adventure demo levels
    - Adds an option to get smoother jump curves when releasing the jump button early
    - Adds better movement speed management when using a weapon
    - Improves Fader's reliability and options
    - InputManager's ControlsModeDetection() is now public
    - Adds an option to mute all sfx on pause
    - Adds a new InitiateDash method to the CharacterDash class to make it easier for AI scripts to use dashes
    - Adds an option to authorize jumps only on the ground or from ladders
    - Adds an option to add items to the inventory before starting a level
    - Fixes a bug that could cause erroneous weapon rotation when certain rotation bound values were set
    - Fixes a bug that wouldn't reset look up distance when walking left
    - Fixes minor lives related bugs
    - Fixes the RetroCorgi's death animation
    - Fixes a typo that prevented points reset in the LevelManager's SoloModeRestart
    - Fixes situations where the RetroAdventure's points counter would be badly positioned on screen

    As usual, expect a few days/weeks of delay for Unity to accept the new version. I hope you'll like these new features, and let me know if you find anything weird!
     
    NAiLz, CHEMAX3X, Zehru and 5 others like this.
  8. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    @reuno WeaponAim works fine for player control. I just wondered if it has been used for AI. I'm trying to read it carefully and see how I might implement an AI control of the WeaponAim script but I was just wondering if someone had already done that before.
     
  9. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Hi,

    I just got a small question about how I should do thing. I want to make a coop game and for that, I will implement a dynamic split screen camera since it's don't seems to exist in the current engine. When players are nearby, there will be only one camera but when they need to be on different rooms, I will create two cameras.

    Does the best way is to make my own level manager and camera controller script ? I think both should implement the native corgi engine script, they will just need somes functions to set wich camera should be assign to wich player. And also, add a mergeCamera options to the level manager to merge the two camera when player are in the same area.

    Does this seems right or do you have any tips to help me make a better implementation ?

    Thanks
     
  10. supermarten

    supermarten

    Joined:
    Oct 12, 2014
    Posts:
    9
    Hi again,
    A small weirdness question. I noticed the CanGoBackToOriginalSize() in the controller returned false at weird times. After some investigation I found that in that function, the line that says:
    _originalSizeRaycastOrigin.y = _boxCollider.bounds.max.y + _smallValue;
    probably should say min.y, which I think it does in other versions of the engine.

    I can't recall I've touched anything in that class, but who knows. Just wanted to check if changing to min is correct?
     
  11. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    @reuno With the inventory engine I would like to be able to click on a hotbar item to use it. Its currently bound to a key. What is the best way to achieve this?

    EDIT: What I have done so far is create a new script which listens for the MMInventoryEvent's. When it receives one it will fire the use method on the InventoryItem if its valid. I assume this is the best way to manage this? Would be great to have a clickable option built into the engine though.
     
    Last edited: Mar 16, 2018
  12. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @NAiLz > Alright!
    @Levrault > Sounds good to me. Not sure why you'd need to override the LevelManager class though, but there really isn't only one way to do things, and the good one is really the one that works for you :)
    @supermarten > I'm not sure what version you're using but this line hasn't been there for a long time. You probably should update to a more recent version of the engine. In any case, that's definitely max, not min. That raycast starts from the top of the head, not the bottom of the character.
    @mimminito > Suggestion noted! It's hard to implement all possible UI interactions as everyone wants something different visually, that's why with the Inventory Engine I focus on the hard, underlying logic, and not much on the visual aspect of it, which is really just native Unity.
     
    NAiLz likes this.
  13. MudPuppet

    MudPuppet

    Joined:
    Aug 10, 2012
    Posts:
    162
    Hey Reuno, much thanks for the Retro Adventure stuff as it has worked out the best solution along with TileMapping for my little platformer project. Hehe, and now you have added character selection and that is freaking awesome!
     
  14. supermarten

    supermarten

    Joined:
    Oct 12, 2014
    Posts:
    9
    Thanks for your answer. I updated but I still don't get it. My problem is illustrated in the image.
    Here I've crouched below a ceiling way above the character's head. But he won't stand back up because it registers as being in a tunnel. The rays cast by that function looks to go too high. Am I missing something?
     
    Last edited: Mar 17, 2018
  15. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Hello, I'd like to use the the player keys also in the Android-mode, to test my game in the unity-IDE and on mobilephone. How can i do this?
     
  16. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @MudPuppet > I'm glad you like the updates!
    @supermarten > Again, what version are you using? Where in any of the demo levels does the problem happen?
    @knuppel > I don't know, it doesn't seem to have anything to do with the engine, does it? Seems like a general Unity question. Never tried that myself.
     
  17. supermarten

    supermarten

    Joined:
    Oct 12, 2014
    Posts:
    9
    I'm on version 4.4.
    It seems to happen when you have "Resize Collider When Crouched".
    I didn't find it setup like that in any demo scene. But if you take Mesa1 for example and change the corgi player to Resize Collider When Crouched and set his crouch collider box y to 0.5 you can see that the tunnel check rays go too far above his head.

    (in the screenshot I've only changed the above setting and moved a platform from the level to test it)
     

    Attached Files:

  18. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @supermarten > Oh but you can control the length of these rays, it's built-in. From the CorgiController's inspector you can set the CrouchedRaycastLengthMultiplier to tweak them to match your character :)

    As explained in the documentation : "by default, the length of the raycasts used to get back to normal size will be auto generated based on your character's height, but here you can specify a different value"
     
  19. supermarten

    supermarten

    Joined:
    Oct 12, 2014
    Posts:
    9
    Ah sorry, I interpreted that as _current_ height. Then I get it :)
    Thanks!
     
    reuno likes this.
  20. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    You were right about the level manager. I just thought that I needed it to link my camera with my player. But I made my own Camera Manager and I made it work. I even could set a dynamic split screen based on where the player go. If he leaves the other player by the right side, he will appear on the right splitted camera. If he leave on the left side, he will be on the left splitted camera.

    I really love your engine. So easy to override and add my own module.
     

    Attached Files:

    Muppo and NAiLz like this.
  21. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    I need some more description of the LoadingSceneManager.LoadScene(). I created a scene with some graphical elements and added a script with:

    using UnityEngine;
    public class Loader : MonoBehaviour {
    // Use this for initialization
    void Start () {
    LoadingSceneManager.LoadScene("Minimal4Players");
    }

    // Update is called once per frame
    void Update () {

    }
    }


    But the screen keeps black and after a few time the next scene is loading.
     
  22. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @supermarten > I'm glad it's working now! Should I change the documentation text to make it more clear?
    @Levrault > That split camera is very nice, it's always great to see people expand on the engine like that :)
    @knuppel > Did you read the loading scene manager's documentation first? Do you get any error? You're trying to load a new scene on Start, that seems unusual.
     
  23. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97

    If you want to provide a better experience to your player, you can use the [B]Loading Scene Manager[/B] :

    [LIST]
    [*]it can be called from [B]anywhere[/B], you don’t have to have a LoadingSceneManager in your scene
    [*]it handles loading (as the name implies), showing an [B]animation[/B] and a [B]progress bar[/B]
    [*]it’s completely [B]customizable[/B], just edit the Common/LoadingScene scene’s contents. You can easily add your own logo, change the look of the progress bar, what animation is playing, etc.
    [*]it’s pretty [B]simple[/B] to use
    [/LIST]
    To use the LoadingSceneManager API, when you want to change level, just call the LoadingSceneManager.LoadScene (string sceneToLoad) method. The string parameter you pass must of course [B]match[/B] the name of the scene you’re trying to load. So if you were to load the minimal demo multiplayer level for example, you’d use :

    Well, that's all of your documentation. Do you have any coding example to use the manager in a load scene?
     
  24. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @knuppel > There's a bit more to it (not including the separate API documentation) :
    upload_2018-3-17_18-19-18.png
    And I'm wondering if adding more documentation for what is essentially a one liner, that mimics Unity's own API, wouldn't be a little overkill. I'm open to suggestions though!

    It's also used to load all of the exit scenes in all of the demo scenes. You can find examples of it by looking for it in your IDE, or in the FinishLevel class for example.
     
    Zehru likes this.
  25. supermarten

    supermarten

    Joined:
    Oct 12, 2014
    Posts:
    9
    That's up to you, I might just have read it wrongly because I was so set on how I thought it would work.
    But if it said something like:
    "by default, the length of the raycasts used to get back to normal size will be auto generated based on your character's ORIGINAL height,"
    then I guess there would be less ambiguity.
     
  26. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88

    @Levrault Great work with that split cam! I'd love to know what technique you ended up using to make it happen. I haven't gotten around yet to experimenting with the idea.
     
  27. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @supermarten > I'll change that for the next release then, thanks for your feedback!
     
  28. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    I've just uploaded a new tutorial to the Corgi Engine's youtube channel :


    This one covers the following points :
    - how to go from scene to scene
    - how to move from a scene section to another
    - how to link entry points in your scenes
    - how to save progress
    - how to setup level selection
    - how to setup character selection

    So basically most of the stuff introduced recently and that hadn't had its own dedicated tutorial yet :)
    I hope you'll like it!
     
    Bhanshee00, Zehru, Beldrama and 4 others like this.
  29. Greenman76

    Greenman76

    Joined:
    Jan 8, 2013
    Posts:
    6
    I'm looking to add animations on hurt and on death. I got the death animation to work on AI but not on the player and not sure where to call the animations for hurt. I've been browsing through the various controllers but have yet to find where it should go.
     
  30. zero_equals_zero

    zero_equals_zero

    Joined:
    Jun 7, 2014
    Posts:
    89
    Thanks for your answer, why I posted it here is because ShootAxis = MMInput.ProcessAxisAsButton(_axisShoot, Threshold.y, ShootAxis); as I thought it could capture the triggers as they are axis. I do know how to do it manually as suggested in the docs. I just thought there was a built in way. Cheers
     
  31. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Thanks :) It's still very basic, but I will try to explain how I did it. I created a quick github rep and maybe I will updated it in the future.

    First of all, I created three camera in my scene, a main, a left and right. For the left and right, I set the viewport rect to 0.5 to make it take only half of the screen.


    After that, I created a SplitScreen script that extend the camera controller from corgi's engine. It will replace the camera controller for the left and right camera (main can still use camera controller). I only use this script to create a SetTarget method since the _target variable is used by the CameraController to set who gonna be watched by the camera.

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using MoreMountains.CorgiEngine;
    6. using MoreMountains.Tools;
    7.  
    8. namespace CameraUtils {
    9.   /// <summary>
    10.   /// Extends corgi's camera controller just to set the target
    11.   /// </summary>
    12.   public class SplitScreen : MoreMountains.CorgiEngine.CameraController {
    13.  
    14.         /// <summary>
    15.         /// Set new target
    16.         /// </summary>
    17.         /// <param name="target"></param>
    18.     public void SetTarget(Transform target) {
    19.             _target = target;
    20.     }
    21.   }
    22. }
    After that, I made a second script called SplitScreenManager. Like LevelManager and GameManager, I added it to my scene in an empty object at the root of the hierarchy. The script calculated when the two player are to far await with the DistanceBeforeSplitting variable when they are two far from each other, it show the left/right camera and when they are closer it show the main one. I used the SetTarget method to set the player to the right camera if he leaves the second character by the right and to the left camera if he leaves him by the left.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MoreMountains.CorgiEngine;
    5. using MoreMountains.Tools;
    6.  
    7. namespace CameraUtils {
    8.   /// <summary>
    9.   /// Calcule when player are two far away from each other and create a split screen.
    10.   /// When they get closer to each other, we go back to a full screen
    11.   /// </summary>
    12.   public class SplitScreenManager : MonoBehaviour {
    13.     public enum CameraBehaviors { Single, SplitScreen };
    14.         [Header("Full Screen Camera")]
    15.         [Information("The Full Screen Camera is the camera that take all the screen.",MoreMountains.Tools.InformationAttribute.InformationType.Info,false)]
    16.     public Camera MainCamera;
    17.         [Header("Split Screen Camera")]
    18.         [Information("Set your left and right camera. Will display when player get a distance greater than the distance before splitting option.",MoreMountains.Tools.InformationAttribute.InformationType.Info,false)]
    19.     public Camera LeftCamera;
    20.     public Camera RightCamera;
    21.         [Header("Option")]
    22.         [Information("When camera should be splitted",MoreMountains.Tools.InformationAttribute.InformationType.Info,false)]
    23.     public float DistanceBeforeSplitting = 10f;
    24.     private CameraBehaviors _CameraBehavior = CameraBehaviors.Single;
    25.     private Transform _target1;
    26.     private Transform _target2;
    27.     private SplitScreen _splitScreenLeft;
    28.     private SplitScreen _splitScreenRight;
    29.  
    30.     // Use this for initialization
    31.     void Start() {
    32.       _splitScreenLeft = LeftCamera.GetComponent<SplitScreen>();
    33.       _splitScreenRight = RightCamera.GetComponent<SplitScreen>();
    34.       _target1 = LevelManager.Instance.Players[0].transform;
    35.       _target2 = LevelManager.Instance.Players[1].transform;
    36.     }
    37.  
    38.     void LateUpdate() {
    39.       float distance = Vector3.Distance(_target1.localPosition, _target2.localPosition);
    40.  
    41.       if (distance > DistanceBeforeSplitting) {
    42.         _CameraBehavior = CameraBehaviors.SplitScreen;
    43.         // going left
    44.         if (_target1.localPosition.x < _target2.localPosition.x) {
    45.           _splitScreenLeft.SetTarget(_target1);
    46.           _splitScreenRight.SetTarget(_target2);
    47.         } else { // going right
    48.           _splitScreenLeft.SetTarget(_target2);
    49.           _splitScreenRight.SetTarget(_target1);
    50.         }
    51.  
    52.       } else {
    53.         _CameraBehavior = CameraBehaviors.Single;
    54.       }
    55.  
    56.       ToggleCamera();
    57.     }
    58.  
    59.     /// <summary>
    60.     /// Enable/disable camera depending on
    61.     /// the display mode
    62.     /// </summary>
    63.     void ToggleCamera() {
    64.       bool isSplitScreen = (_CameraBehavior == CameraBehaviors.SplitScreen);
    65.       MainCamera.gameObject.SetActive(!isSplitScreen);
    66.       LeftCamera.gameObject.SetActive(isSplitScreen);
    67.       RightCamera.gameObject.SetActive(isSplitScreen);
    68.     }
    69.   }
    70. }
     
    NAiLz, Muppo and limo like this.
  32. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @Greenman76 > The hurt animation is not built in. You can easily add one by extending Health and triggering whatever animator parameter suits you. I'm gonna add that to the todo list though, it should be there, thanks for the suggestion.
    @zero_equals_zero > Well MMInput.ProcessAxisAsButton does capture the triggers, it's actually used in the engine to grab the RT (the right one) on xbox pads, and treat them as if they were buttons, not axis. No need to create a dedicated method to capture triggers and treat them as axis, as the native API does that already.
    @Levrault > Thanks a lot for sharing this! Can I add that to the public extension repository?
     
  33. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Yop no problem, you can add it. I will keep you in touch for the futur version :)
     
    NAiLz and reuno like this.
  34. WannabeARG

    WannabeARG

    Joined:
    May 21, 2015
    Posts:
    4
    Hi Reuno and everybody

    I am really happy with this asset
    I´d moved my project to the last Unity version and after one week of work I made this project





    With enough time to make the art, effects, and also a tumblr :)
    https://thedayweshouldrun.tumblr.com

    Its really easy to extend classes to make what I want, incredible fast to use

    Reuno, chapeau!, you made a really good work

    The Day We Should Run is just starting
    I feel it will be a finished game in some months
    I am enjoying developing each level, working more on the gameplay than fighting with the code

    thanks to the Corgi Engine :)
     
    CHEMAX3X, mimminito and reuno like this.
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @WannabeARG > Thanks a lot for sharing this!
    Love the visuals, pretty unique, congratulations! And the whole thing feels very snappy!
    I'll be happy to share this and add it to the showcase when you release it, if you want. Just let me know!
     
  36. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Hello,
    how can i get the user-points to use it in my own script?
    (And set the user points from another script)

    knuppel
     
    Last edited: Mar 19, 2018
  37. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @knuppel > The user-points? You mean the score?
    It's all explained in the GameManager's documentation.
     
  38. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Do you have a little code example? To get and set the score?
     
    Last edited: Mar 19, 2018
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @knuppel > As for pretty much everything in the asset, there are examples of all the methods and classes, directly in the asset. Again, all you have to do to find them is use your IDE's search function. I'm happy to help, sure, but really it'd be much faster for you to just look at the documentation.

    Let's give it a try, in MonoDevelop :
    upload_2018-3-19_16-14-24.png

    Ok so things seem to happen in Coin and GameManager.
    If we look at the Coin class, we'll see an example of how to trigger a point event, that will add more points to our current score.

    And if we look at GameManager, we'll see how this is handled there.

    Note that all this is also explained in the functional documentation :
    upload_2018-3-19_16-15-57.png

    And in much more details in the API documentation :
    upload_2018-3-19_16-16-37.png

    Note that you'll also find that there are also public methods on the Game Manager to add / set points directly if you prefer not using events.

    So long story short :
    - To add points : MMEventManager.TriggerEvent (new CorgiEnginePointsEvent (PointsMethods.Add, 10));
    - To set points : MMEventManager.TriggerEvent (new CorgiEnginePointsEvent (PointsMethods.Set, 10));
    - To read points : GameManager.Instance.Points

    Remember to check the source and documentation next time :)
     
  40. Greenman76

    Greenman76

    Joined:
    Jan 8, 2013
    Posts:
    6
    Thanks, this is what I have so far

    In Health I initialize "Hurt" under InitializeAnimationParameters, then send a trigger update under damage. The animation plays fine but then I get:

    NullReferenceException: Object reference not set to an instance of an object
    MoreMountains.Tools.MMAnimator.UpdateAnimatorTrigger (UnityEngine.Animator animator, System.String parameterName, System.Collections.Generic.List`1 parameterList) (at Assets/CorgiEngine/MMTools/MMHelpers/MMAnimator.cs:40)
    MoreMountains.CorgiEngine.Health.Damage (Int32 damage, UnityEngine.GameObject instigator, Single flickerDuration, Single invincibilityDuration) (at Assets/CorgiEngine/Common/Scripts/Agents/Core/Health.cs:223)
    MoreMountains.CorgiEngine.DamageOnTouch.SelfDamage (Int32 damage) (at Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:222)
    MoreMountains.CorgiEngine.DamageOnTouch.OnCollideWithDamageable (MoreMountains.CorgiEngine.Health health) (at Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:203)
    MoreMountains.CorgiEngine.DamageOnTouch.Colliding (UnityEngine.Collider2D collider) (at Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:165)
    MoreMountains.CorgiEngine.DamageOnTouch.OnTriggerEnter2D (UnityEngine.Collider2D collider) (at Assets/CorgiEngine/Common/Scripts/Agents/Damage/DamageOnTouch.cs:127)

    As for the player death animation, I still haven't dissected the code enough to find where I should call that.
     
  41. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    @Levrault Thanks. This is awesome.

    @reuno I was wondering if there's a simple way to keep AI facing the player they have targeted. I'm trying to use the Character.flip() method but it doesn't seem to have any affect.
     
  42. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @Greenman76 > I can't guess why you're getting this error like that, sorry. It looks like your animator is not set, but it could be tons of different things really.
    @NAiLz > Using the Face method would probably be the best way.
     
    NAiLz likes this.
  43. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
  44. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Thanks you :) I really feel proud of myself.

    But I got small problem. I was working on the split screen manager to correct a annoying issues. When the game goes on split screen mode, the camera slowly move to the player position. It feel kinda unatural. I try to correct this by invoking the TeleportCameraToTarget function of camera controller, so the camera will be at the new player position when the split mode is activated.

    Code (CSharp):
    1.     void LateUpdate() {
    2.       float distance = Vector3.Distance(_target1.localPosition, _target2.localPosition);
    3.  
    4.       if (distance > DistanceBeforeSplitting) {
    5.         _CameraBehavior = CameraBehaviors.SplitScreen;
    6.         // going left
    7.         if (_target1.localPosition.x < _target2.localPosition.x) {
    8.           _splitScreenLeft.SetTarget(_target1);
    9.           _splitScreenRight.SetTarget(_target2);
    10.         } else { // going right
    11.           _splitScreenLeft.SetTarget(_target2);
    12.           _splitScreenRight.SetTarget(_target1);
    13.         }
    14.  
    15.         // teleport to target
    16.         _splitScreenLeft.TeleportCameraToTarget();
    17.         _splitScreenRight.TeleportCameraToTarget();
    18.       } else {
    19.         _CameraBehavior = CameraBehaviors.Single;
    20.       }
    21.  
    22.       ToggleCamera();
    23.     }
    But when I invoke the function, I got this weird problem when only the background color of my camera are show (see the attached file). I still can see the particule effect but I cannot see the rest of the scene. Do you got any idear why I get this screen ?
     

    Attached Files:

  45. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @Levrault > It's hard to tell because the Transform component of your camera is folded in this screenshot, but maybe that's because you've moved the camera on the z axis, and so its x and y are fine but your characters/platforms are now out of the frustum.
     
  46. Levrault

    Levrault

    Joined:
    Jan 22, 2018
    Posts:
    29
    Thanks you, by settings the camera offset to 0,0,-10 fix the issue.
     
  47. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
  48. EWinter

    EWinter

    Joined:
    Feb 20, 2018
    Posts:
    2

    How to achieve it,the jumping in the example.It can jump from a wall to another
     
  49. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @EWinter > That's the walljump ability. It's set by default on most demo characters.
     
  50. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    @reuno I've got an if statement that's attempting to control this using the direction of the player from the mob, in FixedUpdate but it isn't flipping the character sprite to face the character. The direction is registering fine I've placed a debug log in there to make sure the if statement is working properly and it is but for some reason the facing isn't changing:


    Code (CSharp):
    1.         direction = targetPlayerScript.target.transform.position.x > transform.position.x ? 1f : -1f;
    2.  
    3.         if(direction >= 1f)
    4.         {
    5.             character.Face(Character.FacingDirections.Right);
    6.         }
    7.  
    8.         if(direction <= -1f)
    9.         {
    10.             character.Face(Character.FacingDirections.Left);
    11.         }

    Any idea what might be wrong?