Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

NyanYann

15
Posts
53
Followers
1
Following
A member registered Apr 20, 2020 · View creator page →

Creator of

Recent community posts

I mean that if you remove "using UnityEngine.UI" from the file that use the type "Slider" it will cause issues either way because it's the namespace that contains the "Slider" type. 

Did you try to install my package on a new project? If you have Unity UI installed it should work. But it seems to be a common issue maybe you can find more info on how to solve that here https://forum.unity.com/threads/solved-the-type-or-namespace-ui-does-not-exist-i... 

UnityEngine.UI is indeed a valid Unity namespace https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.UI.html and it's a built-in package in Unity, Maybe you have it disabled in the package manager? (Window->Package Manager ->Select Package: Built-in -> Search for the package named "UI") It's strange since it's also supposed to be a dependency of the Input System package.  Either way the UI elements are not really supposed to be used as-is, it's mostly an implementation example so you could just remove those files either way and use your own UI.

And the reason the type "Slider" is not recognized is most probably because you don't have the UI package not because I don't know how to type (Errors like that are usually caused by how your project is setup since Unity has a lot of package that can be enabled or disabled)

I don't seem to have any issue using Unity 2022.3, so please make sure that you :

  • Install the Input System and Cinemachine package (To install a package from Unity go to Window -> Package Manager -> Search for the name of the package and install the plugin (if you can't find it in the results make sure that you set the list of packages to display the content of Unity registry at the top left of the window))
  • Make sure your project uses the new Input System package (Edit -> Project Settings -> Player -> Other Settings -> Active Input handling -> Input System Package (new)

and restart the editor afterward, if you still face some issues try to re-import the plugin after that, if even after that it still doen't work, feel free to tell me

This plugin has only been tested up to Unity 2021, I'll try to look into what could be causing the issue and update it when I have time

Hello, which Unity version are you using?

(3 edits)

Hey, which Unity version are you using ? Also from what I see most of those error are caused by a missing dependency, the sample project use the new input system so it needs to be installed in the package manager and activated for those errors to go away https://docs.unity3d.com/Manual/com.unity.inputsystem.html

You can use them however you want without having to credit me, they where created solely for this project.

In the sample project you can look at the "Player_Close" game object (which is disabled by default), but in a general case you need to add a "Top Down Melee" component to your character (in which you will need to add a reference to a prefab containing a "Melee Attack Controller" component), and changes its "attack config" in its "Character Stats Handler" component to be a Melee attack config (in the sample project there is the "PlayerSwordSlash" config. I don't know if that's what you wanted. 

You could theoretically just edit the InputAction file of your Player to add ways to triggers the Move, Look and Fire events with touch controls. However i don't think just doing this would work very well so you might need some kind of virtual joystick and buttons or at least a custom version of my "TopDownInputController" script. I might try to implement touch controls later but not in the near future.

In order to add a new mechanic (something that needs a new input other than the existing ones) you have a few steps to do:

  1. Edit the Unity's Input asset (located in Sample/Input/Top Down Controller 2D in the example) to add a new input to read
  2. Create a new event for this input in the TopDownCharacter2D.Controllers.ControllerEvent class by following the existing examples (for a dodge mechanic I think you want your event to extend the UnityEvent<Vector2> 'class' since you want to dodge in a specific direction I would imagine)
  3. Add your new event to the TopDownCharacterController class (simply add a private readonly field and a public getter like the other events)
  4. Now if you want the player to be able to use your new mechanic you need to update your player controller (your class extending the TopDownCharacterController class / the TopDownInputController class in the example). 
  5. In this class you will need to create a method to receive the input from the input system (like the OnMove and OnLook methods of this class) for a dodge mechanic i think you will need to keep a direction in memory and when you press the button you create a OnDodgeEvent with the direction stored (using the look direction should work quite well)
  6. Now you only need to create a new component to handle this specific event. In order to write this component you can look at the TopDownMovement, TopDownAimRotation, TopDownShooting... classes which basically work the same way. 
    1. You need to store your controller using "GetComponent<TopDownCharacterController>" in the Awake method
    2. Add a listener to the event you want to handle (OnDodgeEvent in this example)
    3. And finally, actually perform the logic of the mechanic in the method

Now as for the dodge mechanic in itself i think you should use a Coroutine (https://docs.unity3d.com/Manual/Coroutines.html) which will simply disable collision between the player and enemies / bullets and some components like TopDownMovement and HealthSystem for a given time. I think this page can be a good start https://docs.unity3d.com/ScriptReference/Physics.IgnoreLayerCollision.html

If you want a specific animation for the dodge you can look into the TopDownAnimation class and add a listener on the OnDodgeEvent.

These steps should help you to add a new mechanic to the controller, but if you encounter any problem or don't understand a step don't hesitate to ask me in the future i plan on writing a small documentation properly to answer those kind of questions.

I uploaded a new version compatible with Unity 2019

I'm working on porting it to Unity 2019, however if that's not a problem for you you can try to use Unity 2020 and it should work properly.

Which Unity version are you using ?

It was only mentioned in the installation instructions but its easy to miss so I added it in the description now. However if it's a problem for you, porting it to the old input system should be really easy since only the controller would need to be reworked (I might add an example with the old input system later)

I added a link to the source code of this project in the description (it should be up to date but I did not check thoroughly). Also note that the code is quite dirty since I started this game only to discover the NEZ engine for Monogame.