Skip to content

Marioexplo/Reusable-Unity-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reusable-Unity-scripts

Here I leave some Unity scripts I think can be useful. I'm only at the beginning of my journey with Unity and C# and, until now, the only games I made were experiments, so I haven't published anything, yet. Anyway, before focusing on the next game I have in mind, I wanted to make some scripts I can reuse in the future. I'm sure I haven't created anything new but I can't find any reason why I shouldn't share my code here.

Description and how-to-use:

  • BackAndForth (class): this static class contains functions you can always use without needing to store it in a variable. You can:
    • Move back and forth on the vertical or horizzontal axis. Perfect for moving platforms.
    • Do that and store the movement value in a variable. Perfect if you need to move a character on the moving platform.
    • Move back and forth horizzontally and mirror the object to face the movement direction.
    • Do the first and the third with a rigidbody, but, before using the function, you'll have to set a speed or put the object at the edge of the given limited space.
  • PBackAndForth (struct): the P stands for Personal, in fact it works as (and with) BackAndForth but you can set speed and minimum and maximum postion when declairing the struct, and you don't need a direction variable to reference.
  • FollowCamera(2D) (component): it makes the given camera follow the object the MonoBehaviour is on. You can decide the ratio, a number between 0 and 1 which defines how fast the acceleration will be, and you can set borders outside of which the camera can't go.
  • TextScroll (component): a component to scroll texts of different kinds, for all situations. You just have to set the time to scroll a letter and then set the text(s), which are of different types:
    • A simple string ("simple");
    • An array of strings ("array");
    • An array of Branches ("structure").
    • AutoArray: when you use the array type, you can enable this to automatically pass from a text of the array to the next one. You can also set the time this action will take.
    • Branch: this is a custom struct which contains a name (of the branch) and the text which will be scrolled. It works as the array but instead of setting the array's number of the text to scroll, you'll set the branch' name.
  • SafeDestroy (class): destroy a component or a GameObject after deactivating it, this way you ensure non more actions will be made by these.

About

Here I leave some Unity scripts I think can be useful

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages