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

[RELEASED] TopDown Engine by More Mountains [new v1.8 : room system, performance manager...]

Discussion in 'Assets and Asset Store' started by reuno, Oct 9, 2018.

  1. Alai

    Alai

    Joined:
    Feb 14, 2009
    Posts:
    15
    I am trying to get a single frame sprite to rotate with the direction of movement (and also shoot in that direction). Therefore, I'm overriding CharacterOrientation2D, and I detect input to prevent the orientation from changing too fast when I have two keys pressed for a diagonal. It kind of works, but the weapon facing still has the "diagonals released quickly point in the direction of the last key pressed". I'm setting _targetModelRotation for this, and I'm guessing there's something similar for weapon rotation.

    This seems complex for the result, and it's only mostly reliable.

    Am I on the right track here?

    My code:


    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.Runtime.CompilerServices;
    5. using UnityEngine;
    6. using MoreMountains.Tools;
    7. using UnityEngine.Serialization;
    8.  
    9. // ReSharper disable once CheckNamespace
    10. namespace MoreMountains.TopDownEngine
    11. {
    12.     /// <summary>
    13.     /// Add this ability to a character and it'll rotate or flip to face the direction of movement or the weapon's, or both, or none
    14.     /// Only add this ability to a 2D character
    15.     /// </summary>
    16.     [AddComponentMenu("TopDown Engine Override/Character/Abilities/Character Orientation 2D Changed")]
    17.     // ReSharper disable once InconsistentNaming
    18.     public class CharacterOrientation2D_Changed : CharacterOrientation2D
    19.     {
    20.      
    21.         /// whether we should rotate the model on direction change or not      
    22.         [MMCondition("ModelShouldRotate", true)]
    23.         public bool modelShouldRotateAbsolute;
    24.        
    25.         //[MMCondition("ModelShouldRotate", true)]
    26.         private int redirectDelayTimeMs = 50;
    27.        
    28.         private int waitForRotateDelayTimeMs = 0;
    29.    
    30.         private Vector3 _prevRotationVector = Vector3.positiveInfinity;
    31.         private Vector3 _nextRotationVector = Vector3.positiveInfinity;
    32.         private DateTime _lastRotationTime;
    33.  
    34.         protected override void RotateModel(int direction)
    35.         {
    36.           if (false == modelShouldRotateAbsolute)
    37.           {
    38.             base.RotateModel(direction);
    39.             return;
    40.           }
    41.            
    42.           if (null == _character.CharacterModel)
    43.           {
    44.             return;
    45.           }
    46.          
    47.  
    48.           DateTime curTime = DateTime.Now;
    49.           if (false == this.NextActionTimeHasElapsed(curTime))
    50.           {
    51.             return;
    52.           }
    53.  
    54.           if (true == this.IsReadyToRotate())
    55.           {
    56.               if(
    57.                   (Character.CharacterTypes.Player ==  _character.CharacterType)
    58.                   && (0 == _inputManager.PrimaryMovement.magnitude)
    59.                   )
    60.             {
    61.               Debug.LogWarning("Cancelling rotation - player character input stopped");
    62.               this._prevRotationVector = Vector3.positiveInfinity;
    63.               this._nextRotationVector = Vector3.positiveInfinity;
    64.               return;
    65.             }
    66.           }
    67.  
    68.           this.SetTargetModelRotation(this._nextRotationVector);
    69.  
    70.           Vector3 curMovement = _controller.CurrentDirection;
    71.           Vector3 newRotationVector = NewRotationVector(curMovement);
    72.           if (false == this.HasRotationChanged(newRotationVector))
    73.           {
    74.               return;
    75.           }
    76.          
    77.           this._prevRotationVector = newRotationVector;
    78.           this._lastRotationTime = curTime;
    79.  
    80.           Vector3 facingRotationVector = FacingRotationVector(newRotationVector);
    81.           Debug.LogWarning( " Facing rotation has changed to " + facingRotationVector);
    82.           this._nextRotationVector = facingRotationVector;
    83.         }
    84.  
    85.  
    86.         private bool NextActionTimeHasElapsed(DateTime curTime)
    87.         {
    88.           TimeSpan rotationTimeSpan = curTime - this._lastRotationTime;
    89.           double msSinceLastRotation = rotationTimeSpan.TotalMilliseconds;
    90.           if (msSinceLastRotation < redirectDelayTimeMs)
    91.           {
    92.             return false;
    93.           }
    94.           if (msSinceLastRotation < waitForRotateDelayTimeMs)
    95.           {
    96.             return false;
    97.           }
    98.  
    99.           this.waitForRotateDelayTimeMs = 0;
    100.           return true;
    101.         }
    102.  
    103.         private bool IsReadyToRotate()
    104.         {
    105.           if (true == Vector3.positiveInfinity.Equals(this._nextRotationVector))
    106.           {
    107.               return false;
    108.           }
    109.  
    110.           return true;
    111.         }
    112.  
    113.         private void SetTargetModelRotation(Vector3 rotationVector)
    114.         {
    115.             if (false == this.IsReadyToRotate())
    116.             {
    117.                 return;
    118.             }
    119.          
    120.           this._nextRotationVector = Vector3.positiveInfinity;
    121.          
    122.           this.waitForRotateDelayTimeMs = 0;
    123.        
    124.           Debug.LogWarning("State " + _character.MovementState.CurrentState + "Changing facing rotation to " + rotationVector);
    125.           this._targetModelRotation = rotationVector;
    126.           //_targetModelRotation = _controller.CurrentMovement;
    127.           //_targetModelRotation.x = _targetModelRotation.x % 360;
    128.           //_targetModelRotation.y = _targetModelRotation.y % 360;
    129.           this._targetModelRotation.z = _targetModelRotation.z % 360;
    130.         }
    131.  
    132.         private bool HasRotationChanged(Vector3 newRotationVector)
    133.         {
    134.             if (true == this._prevRotationVector.Equals(newRotationVector))
    135.             {
    136.               return false;
    137.             }
    138.            
    139.             return true;
    140.         }
    141.  
    142.         private Vector3 NewRotationVector(Vector3 curMovement)
    143.         {
    144.             float xComponent = 0;
    145.             float yComponent = 0;
    146.             float zComponent = 0;
    147.            
    148.             if (curMovement.x > 0)
    149.             {
    150.                 if (curMovement.y < 0) { zComponent = -45; }
    151.                 else if (curMovement.y > 0) { zComponent = 45; }
    152.                 else { zComponent = 0; }
    153.             }
    154.             else if (curMovement.x < 0)
    155.             {
    156.                 if (curMovement.y < 0) { zComponent = -135; }
    157.                 else if (curMovement.y > 0) { zComponent = 135; }
    158.                 else { zComponent = -180; }
    159.             }
    160.             else
    161.             {
    162.                 if (curMovement.y < 0) { zComponent = -90; }
    163.                 else if (curMovement.y > 0) { zComponent = 90; }
    164.                 //else { zComponent = 0; }
    165.             }
    166.  
    167.             Vector3 newRotationVector = new Vector3(xComponent, yComponent, zComponent);
    168.             return newRotationVector;
    169.         }
    170.        
    171.         private Vector3 FacingRotationVector(Vector3 newVec)
    172.         {
    173.           float additionalRot = 0;
    174.  
    175.           switch (InitialFacingDirection)
    176.           {
    177.             case Character.FacingDirections.West:
    178.               additionalRot = -180;
    179.               break;
    180.             case Character.FacingDirections.East:
    181.               additionalRot = 0;
    182.               break;
    183.             case Character.FacingDirections.North:
    184.               additionalRot = -90;
    185.               break;
    186.             case Character.FacingDirections.South:
    187.               additionalRot = 90;
    188.               break;
    189.           }
    190.        
    191.           Vector3 facingRotationVector = new Vector3(newVec.x, newVec.y, newVec.z + additionalRot);
    192.           return facingRotationVector;
    193.         }
    194.     }
    195. }
    196.  
     
  2. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Alai > I'm not sure if that'd be ok for what you're after (I admit it's not super clear for me) but maybe look at the RotatingKoala prefab, it seems to do what you want.
     
  3. AKAGT17

    AKAGT17

    Joined:
    Sep 8, 2014
    Posts:
    18
    Hi Reuno, for my 3D game, I have set up 3D sliding doors that requires a key to open which I followed the top down engine documentation to set up and I watched your youtube video even though it was 2D. However, I have noticed a bug where whenever my 3D character is in the door box collider area ( is Trigger is ticked) for the Key Operated Zone, my character cant jump . You can try and recreate it in 3D and see, I have also noticed this bug in your KOALA 2D example where whenever you are in the door 2D collider area you cannot jump. Please can you amend this for your next update thanks.
     
  4. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @AKAGT17 > That's normal, and by design.
    By default, the same button (space) is mapped to interact and jump, so there's an extra security to prevent jump.
    You can simply extend CharacterJump (2D or 3D) and change the EvaluateJumpConditions to remove that check if you don't need it. And in general if you think you've found a bug, please use the support form to report it, thanks.
     
  5. AKAGT17

    AKAGT17

    Joined:
    Sep 8, 2014
    Posts:
    18
    Hi Reuno, I am no coder and deal with the art side really, I have no clue and dont know where to start in order to edit the CharacterJump 3D script to achieve what I what. Would you kindly point out which line of code would I need to delete to allow my 3D character to jump in the collider area? Thank you
     
  6. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @AKAGT17 > I can add an option for that to an upcoming release if you want.
    In the meantime, as I said extending would be better, but if you prefer editing, that'd be in CharacterJump3D, and you'd want to remove lines 194 to 201.
     
  7. AKAGT17

    AKAGT17

    Joined:
    Sep 8, 2014
    Posts:
    18
    Thanks! it would be great if you can add an option for it for the next release , that way at least its non destructive,
    thanks Reuno I look forward to it.
     
  8. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    I've pushed a new version (v1.8) of TopDown Engine to the asset store today.
    As with all the engine's updates, this one fixes all known bugs to date, introduces very heavily requested features (the rooms system and dialogues, for the biggest ones), updates MMFeedbacks to their latest version, and overall a lot of cool stuff :

    - Adds the Room system, that lets you divide a level into multiple Rooms (think Binding of Isaac or topdown Zelda games), with unique cameras, custom transitions between rooms and full control over the whole sequence.
    - Adds the KoalaRooms demo scene, showcasing the new Rooms system in 2D
    - Adds the MinimalRooms3D demo scene, showcasing the new Rooms system in 3D
    - Adds dialogue zones, letting you trigger and display short dialogue lines in the world, and examples in Koala2D, MinimalSandbox2D and MinimalSandbox3D
    - Adds a new AI action, AIActionRotateTowardsTarget3D, and an example of it in
    - Adds the MMRandomInstantiator, a class that lets you spawn random objects on initialization
    - Adds the MMAnimatorMirror class, letting you mirror an animator state into another, useful to have a controller or weapon command more than one animator
    - Adds the Stimpack class, a pickable item that instantly heals the picker Character by the specified amount of Health, and an example of it in the Loft3D demo
    - Adds the ProximityManager class, a system you can use to dynamically enable/disable ProximityManaged objects in your scene based on their distance to the player, disabling objects that are far from the camera/action to save on performance. Also adds the MinimalPerformance demo scene, showcasing the difference between a scene with and without that setup.
    - Adds MMDebugMenu, a system you can use to display a debug menu, packed with ready to use controls (sliders, checkboxes, buttons, texts, etc) and a command line console
    - Adds the MMRadio system, to read and broadcast field and property values
    - Adds the MMAnimatorMirror class, letting you mirror an animator state into another, useful to have a controller or weapon command more than one animator
    - Adds the MMRandomInstantiator, a class that lets you spawn random objects on initialization
    - Adds MMLightShaker
    - Adds the concept of range to shakers, letting you only trigger shakers within a certain range to the event emitter
    - Adds MMFeedbacksShaker and MMFeedbackFeedbacks, a feedback that lets you trigger MMFeedbacks on a specific channel and within a certain range.
    - Adds a menu to the sequencers demo
    - Improves button activated zones : adds per-zone customizable input and animation parameter, enter and exit feedbacks, and exit/stay/activation Unity events.
    - Improves 3D falling platforms structure
    - Improves the character collision system and removes now useless extra collider on all character prefabs
    - Adds an option to lock vertical rotation on WeaponAim3D
    - Changes the center of rotation for WeaponAim3D, from weapon to owner
    - CharacterInventory can now work with extended InventoryEngineWeapons
    - Adds an option to disable a character's child colliders on death
    - Adds a normalized method to MMProgressBar
    - Adds a script driven mode and public movement APIs to CharacterGridMovement
    - Adds a second Player Character to MinimalGrid3D
    - Adds two new modes to the Time MMFeedback : Change and Reset, letting you change the timescale indefinitely, until you reset it
    - Adds driven mode to Float and Shader controllers
    - Adds the AlmostIdentity tween to the MMTweens
    - Adds range and shadow strength control to the Light MMFeedback
    - Adds a ToggleSequence method to the MMSequencer
    - Adds RequireComponent when needed to all Actions and Decisions.
    - Adds an extra check to InventorySelectionMarker
    - Adds extra checks to bind weapon and character animators
    - Adds SafeMode to MMFeedbacks to prevent the occasional Unity serialization issue
    - Adds a public InCooldown bool to MMFeedback to check if a specific feedback is in cooldown at any given time
    - Inspector colors now won't be computed outside of the editor
    - Adds tooltips for all classes of the engine.
    - Adds missing comments to MMFeedbackMaterial
    - Fixes a potential wrong init frame on fader round
    - Fixes a few missing scripts
    - Fixes a bug that would cause cached sound feedbacks to not play through the correct audio mixer
    - Fixes a bug that would cause the GridManager to log occupied cells incorrectly
    - Fixes a bug that would cause ItemUsed events to be fired too late in some situations
    - Fixes a bug that would prevent movement after changing weapon mid combo attack if the combo weapon had movement prevention settings.
    - Fixes a wrong path to the loading scene in the documentation

    Expect a few days of delay until Unity approves it.
     
    ItachiTGM, JRBlake, MudPuppet and 2 others like this.
  9. Alai

    Alai

    Joined:
    Feb 14, 2009
    Posts:
    15
    Thanks, I've taken a look and it looks like what I need. Therefore I copied the RoataingKoala, changed the sprite, and removed the animation (so that it would be my sprite without animation, which I don't understand yet). It works almost perfectly, but when I move west (or NW, or SW), it rotates to the east (or NE, or SE), though the direction of travel is what it should be. I've tried both "Smooth" and "Smooth Absolute" for rotation speed. Is there something with an X-axis flip that I'm missing?

    I'm just looking for a "space shooter" type "fly in eight directions and shoot in the direction you're facing" :)
     
    Last edited: May 20, 2020
    reuno likes this.
  10. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    15
    Two questions, can I move the Default sorting layer or is it necessary that it be the layer that's rendered first? Also, and this is not a huge deal but was just curious, is local multiplayer compatible inventory system fairly high on the to do list or should I be looking into making my own? Again not a big deal, you work on what you want, was just wondering.
     
  11. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @nichjaim > Good questions!
    1. Sorting layers are entirely up to you as far as the engine is concerned.
    The engine itself doesn't interact with them at all.

    2. It's relatively high. Not "next update" high, but close :)
     
    nichjaim likes this.
  12. Alai

    Alai

    Joined:
    Feb 14, 2009
    Posts:
    15
    I copied the RoataingKoala, changed the sprite, and removed the animation (so that it would be my sprite without animation, which I don't understand yet). It works almost perfectly, but when I move west (or NW, or SW), it rotates to the east (or NE, or SE), though the direction of travel is what it should be. I've tried both "Smooth" and "Smooth Absolute" for rotation speed. Is there something with an X-axis flip that I'm missing?
     
  13. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Alai > Not really, no. If the issue persists, don't hesitate to send exact (written) repro steps via the support form, I'll be happy to have a look. Must be some wrong setup somewhere, but without more details it's hard to guess what :)
     
  14. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    15
    Is there some built-in way to have the damage of a weapon shot be based on the weapon and character shooting, like base weapon damage plus some character stat, rather than just the projectile? It seems like some other scripts require Weapon script as some kind of base for some of their stuff, like the projectile script, so would it be wise to make a script that extends weapon and then make stuff like projectile weapon script from extending that custom weapon script or would that likely mess with other scripts that need a Weapon script not some WeaponCustom script. Sorry if I'm explaining this poorly, I'm just a little unsure of the best way to go about this.
     
  15. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @nichjaim > There's no built in way to do that. The easiest way would be to extend ProjectileWeapon, and have it modify more properties of the Projectile as it's spawned.
     
    nichjaim likes this.
  16. Zetazed

    Zetazed

    Joined:
    May 16, 2019
    Posts:
    5
    new update looks great. cant wait to test the new stuff :)
     
    reuno likes this.
  17. RadTT

    RadTT

    Joined:
    Nov 9, 2016
    Posts:
    7
    Sorry if this is answered elsewhere - is there any support for Unity's Input System (available in Package Manager) or will there be support in the future?
     
  18. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @RadTT > Not yet, I still don't think it's production ready. When it is, then I'll add support for it.
     
    RadTT likes this.
  19. soxajn

    soxajn

    Joined:
    Sep 1, 2013
    Posts:
    2
    Hey Really love this asset and i have been using it for some time now.
    I just noticed that there is a Character Handler Secoundary Weapon, but i can't seems to figure out how to change, swich or equip weapons to it through the inventory. it is no problem to make it work with the normal weapon handler. Can anyone help?
     
  20. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @soxajn > That's because (out of the box) the inventory ability only talks to the main weapon handler, not the secondary one. I can add that feature to the todo list if you'd like.
     
  21. soxajn

    soxajn

    Joined:
    Sep 1, 2013
    Posts:
    2
    I think that would be cool :) Keep up the good work on this asset :D
     
    reuno likes this.
  22. RadTT

    RadTT

    Joined:
    Nov 9, 2016
    Posts:
    7
    Not sure about the new Input system but the default unity input manager is a huge pain. Do you have any recommendations for some sort of extension that helps streamline that process and works nicely with TopDown Engine? Paid or free, doesn't matter, just something to get me out of that awful UI and into something bearable while not having to alter core TopDown Engine code to make it work.
     
  23. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @RadTT > Most people seem to simply avoid the UI (it's just a text file, it's quite easy to edit), roll their own solution, or use InControl, ControlFreak2 or Rewired. You'll have to extend the engine for anything else other than Unity's default.
     
    RadTT likes this.
  24. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    15
    The example characters I saw seem to have their physical collider also act as their hitbox, is there a way to separate the two so that a char's hitbox can be bigger or smaller than their actual physical collider? Can I just add another collider that's trigger based or would that cause problems? Also can I use circle colliders or is it best that their box colliders, I'm using minimal2D as a basis if that matters. Sorry for so many questions at once.
     
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @nichjaim > Everything's possible, but you'll likely have to tweak stuff a bit to make it work. There's no example like that out of the box.
     
  26. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    175
    I have long been looking at both the corgy engine and the topdown engine. ;)

    From experience i have a few "Pre-buy" questions.
    I have a plan setup, story etc, rouge lite and are starting to evaluate what is needed for my next project which will
    be a game similar to Archero/Butchero/Hunter:MOA and Arcade Hunter which is possible the best of those mentioned.

    And i will have to make some changes to the engine for this to work, i need to be able to collect
    2 types of XP + Weapon XP etc, and some other functionality. Not a issue at all.

    My concern is the scripts, and i was wondering
    - is the scripts commented and functions named sensible?
    - how large are the scripts, some developers tend to create 1000's of line scripts which makes it almost impossible to
    change anything without having a overview of the consequences.
    - I will be adding other assets for my own gameManager might use different namespace and name etc and level generation etc, but i will implement that myself but again it is important that i can read through the scripts..
     
  27. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Vaupell >
    - Yes, scripts are commented, there's a full API documentation, a functional documentation, and video tutorials covering every aspect of the engine.
    - How large they are depends on the scripts. A few may be bigger than 1000 lines (edit : double checked, didn't find one, but there may be), but the engine is built with extensibility as one of its core pillars, so even the larger classes are cut in understandable chunks that you can override to suit your specific needs.
    - not sure if that last one is a question, but sure you can add other assets :)
     
    Vaupell likes this.
  28. Malaussene

    Malaussene

    Joined:
    Feb 14, 2017
    Posts:
    16
    Hi Reuno!

    I'm having a bit of an issue with character flipping when mouse is at 90° or -90°.
    In the inspector I can see the "facing right" toggle is constantly turning on and off.
    I looked for any kind of threshold everywhere but, probably my bad, couldn't find any.
    The character orientation facing mode is set to "Weapon Direction". I tried both model should flip and rotate but the result is the same. Both the character and weapon are built exactly as the prefabs in the Koala demo. Also, all the various settings are the same. Is there something I'm not getting?

    I'll leave you to a gif to better visualize the issue:



    Thanks a lot for the help!
     
  29. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Malaussene > It's hard to tell just from a gif. My guess is there is some difference, otherwise it'd behave exactly the same :) Maybe you've got a x axis offset somewhere. If the issue persists, please send me more info via the support form on how to reproduce your issue, I'll be happy to have a look at it!
     
    Malaussene likes this.
  30. Malaussene

    Malaussene

    Joined:
    Feb 14, 2017
    Posts:
    16
    @reuno > Ok I got it.. and it's kind of obvious. This happens when you move the weapon attachment slot in x positive value (I got the slot on the right hand when facing right, which flips to the left when facing left). This also happens with the Koala character and since everyone loves gifs, here's another:



    That's why I was looking for a rotation treshold of some kind. Do you think there's a workaround for this?

    I can only see the gif in the preview: here's the link https://media.giphy.com/media/USVqf7tmiIX2jF2wZo/giphy.gif
     
  31. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Malaussene > I can add a workaround for that to the todo list if you report it via the support form, sure. It's not a use case the current system was designed for, but it should be easy to add.
     
    Malaussene likes this.
  32. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    Forgot to mention it but, as usual, that way I can send you a fix if you don't want to wait for the next release :)
     
  33. Malaussene

    Malaussene

    Joined:
    Feb 14, 2017
    Posts:
    16
    @reuno Thanks a lot! Just sent the support ticket!
     
    reuno likes this.
  34. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    15
    I'm not quite sure how to word this but, does the engine have simultaneous menu navigation for multiple menus? Like, the game is splitscreen and each screen has their own menu and own player navigating that menu. Is there an easy way to do that or would I need to build some custom stuff?
     
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @nichjaim > No, there isn't, the engine focuses really on top down mechanics, the UI that's there is just standard Unity, meant as a placeholder to let you access the various demos/showcases, it's not a menu solution :)
    So you can build that as easily as you would in any project really. I *think* native UI components would work, as long as you separate navigation, but I don't have a ready made example to point you at.
     
  36. nichjaim

    nichjaim

    Joined:
    Apr 23, 2020
    Posts:
    15
    I can't figure out how these components are getting the player's input values. I understand the input manager is the one actually getting the inputs but I can't figure out how something like CharacterMovement is getting those values from Input Manager. Am I missing something?
     
  37. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @nichjaim > There's a HandleInput in every ability that reads input from the InputManager. You can also learn more about it in the documentation of course. If you have more questions about it, please use the support form, I'll be happy to help, thanks!
     
    nichjaim likes this.
  38. xagarth

    xagarth

    Joined:
    Sep 7, 2016
    Posts:
    10
    Hi @reuno ,

    Again, great stuff here!
    QQ, is there a quick way to bind player movement directions to camera rather than world?
    If I rotate the camera to get different perspective, player movement is still bind to world x,y,z.
    This might be somehow expected, but I'd rather have it bound to camera.

    Thanks,
    X
     
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @xagarth > No, that's not something the engine focuses on at the moment, you'd have to implement it yourself. That steers too far away from top down mechanics, and too close to a thirrd person controller.
     
  40. Malaussene

    Malaussene

    Joined:
    Feb 14, 2017
    Posts:
    16
    Hello @reuno

    I'm trying to implement a ricochet bullet but with very bad results on bounce consistency.
    First of all, for the moment I'm testing this without extending anything, inside the Projectile class rather than on DamageOnTouch (which i see handles all trigger collisions).

    The very basic code I'm using is this

    Code (CSharp):
    1.  
    2. public LayerMask BounceLayerMask;
    3.         private void OnTriggerEnter2D(Collider2D collision)
    4.         {
    5.             RaycastHit2D hit = Physics2D.Raycast(transform.position,Direction);
    6.             if(Physics2D.Raycast(transform.position, Direction,0.5f,BounceLayerMask))
    7.             {
    8.                 Vector2 reflectDir = Vector2.Reflect(Direction, hit.normal);
    9.                 SetDirection(reflectDir, Quaternion.identity, false);
    10.             }
    11.         }
    12.  
    I know that I probably shouldnt be using SetDirection but a dedicated method, but I'm just in the early testing stage.

    As I said I get really unconsistent results on the hits, as nearly anytime the projectile direction is perpendicular to the normal of the hit, the projectile goes trhrough the collider.

    Could I have any hint on a proper way of doing this? Also, would it be better to extend projectile or damageontouch? And a final question.. would using this raycast solution be too resource intensive for mobile?

    And btw... I really hope we'll get an official "ricochet" update soon :D

    Thanks a lot!
     
  41. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Malaussene > No need to extend anything, this could (and probably should) be its own system, it's unrelated to the engine at this point :)
    As for whether or not using raycasts would be too expensive on mobile, that really depends on your context (number of projectiles, CPU budget, target devices, etc). I'd recommend benchmarking to determine what approach would be best here.
     
  42. Malaussene

    Malaussene

    Joined:
    Feb 14, 2017
    Posts:
    16
    Yeah you're right about it. Will make its own class to handle this. Any Idea about the bad consistency issue?
     
  43. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    3,547
    @Malaussene > No, I suppose there's something wrong in your code. I can add bouncy projectiles to the todo list if you'd like.
     
    Muppo and Malaussene like this.
  44. Malaussene

    Malaussene

    Joined:
    Feb 14, 2017
    Posts:
    16
    I would love that :D
     
    reuno likes this.
unityunity