Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. 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

What shouldn't I consider doing programmatically?

Discussion in 'Getting Started' started by Kich867, Jul 28, 2020.

  1. Kich867

    Kich867

    Joined:
    Jan 12, 2018
    Posts:
    14
    I'm a software engineer professionally, designing and implementing large complex systems is basically all I do, it's what I'm used to.

    The more I get into unity, and it's something I sort of knew to an extent already, I realize that many things shouldn't be handled by scripts. I just learned for instance that Camera movement is probably better suited to learning how to use Cinemachine, a really mind blowingly powerful tool. I wasted a solid day doing tutorials for camera movement, trying tons of scripts to get the effect I'm looking for, and it turns out Cinemachine does this and they have examples on how to set it up that I'll be working on tonight.

    And so what I want to know is, where should my instinct be around whether to reach for my keyboard and start scripting, or dig deep into unity's toolbox to find a solution the engine manages already?

    For instance, character movement? Projectile pathing and speed? These are things done in tons of games in almost identical ways, should I expect unity to have an option for these? Do I really need to reinvent the wheel to make a character move with an animation?

    Like what are the things that tons of people write scripts for but unity actually already provides for them they just need to know about them, what am I missing?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    8,759
    A lot of things come down to "it depends". For example projectile pathing and speed, you could manually move projectiles each frame. You could also just use the physics system, apply a force, and let Unity handle things until an OnCollisionEnter method gets called. It depends on what you want from the movement of the projectile.

    I'm working on a game where the player lobs cannonballs at each other. Adding a force when the cannonball is fired and letting Unity actually handle the movement works great. In another project I am looking for a 1980's/90's style movement of the projectiles, so I'm directly moving the objects myself each frame in a straight line.

    But just a few things. You probably should take advantage of the prefab system, instead of generating GameObjects and adding all their components at runtime. You should consider using the physics system where appropriate. You usually will want to use models created in an outside modeling program instead of trying to generating meshes within Unity at runtime. You probably will want to use multiple scenes, and additive scene loading, to separate different parts of your project. Take a look at the CharacterController, which is appropriate for certain types of games.

    Skim through the Unity manual to familiarize yourself with what functionality is built into Unity. Consider using the Unity feature instead of rolling your own. Usually it will at least save yourself some time. (Though sometimes reinventing the wheel is necessary, if the Unity feature doesn't exactly match what you need, or if there are unresolved issues which impact your project)
     
    JBR-games and Lurking-Ninja like this.
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    5,450
    What @Joe-Censored just said! Plus, I would add, that it also depends what you're doing.

    - if you have a concrete plan with details, then you can take some time before you start to work on actual features in detail and you can research what Unity already has on this (or even if the Asset Store has some useful stuff, although be careful with that, the quality and the support on the AS is highly variable), and if you find a good solution, you don't need to write one
    - if you don't have a plan and you're "just" doodling, then I wouldn't research, just put something vague together what does the minimal job done for a prototype and when you see it is feasible or not, you can decide if you want to write it yourself or search for some solutions
    - you also can do some preemptive research, as Joe said, skim through the documentation, Unity offers a lot of cool things
    - you also may want to read/watch through some beginner level tutorials, they usually take you through the basics and show what is the "standard" way of doing things. Those aren't always the best options, but the most beginner friendly ones, but at least you can find out if you're comfortable with those or you want to roll something on your own
     
    JBR-games and Joe-Censored like this.
unityunity