Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by SoulAqua04 · Feb 22, 2017 at 03:20 AM · c#programminggame development

C# for applications vs C# for Unity help

I have been wondering this for quite awhile. I am a new programmer so I will try to explain this to the best of my knowledge.

In Unity, your script might include something like this: transform.position = Vector3.Lerp(transform.position, targPos, Time.deltaTime * speed);

This of course is written in the language C#. But if you are writing in C# not using Unity, you don't have access to things like transform.position or Time.deltaTime, they would only work in Unity.

If this is the case, how would one be fluent in the languge C#? How would professional programmer, be a professional? Would they have to memorize a bunch of functions and things like Vector3 just to make a game? How would they implement a feature if it was their first time, and they were "fluent" in C#?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Zee-Play · Feb 22, 2017 at 03:43 AM

I can tell you how I learned to use Unity. I'm pretty much a hobby coder, 99% self taught. Had absolutely no idea how to write C# language when I picked up unity, only a few memories from basic coding back in highschool 8 years ago.

I started out by looking at examples, trying out simple stuff, and searching unity answers and the unity manual every time I hit a rock in the road.

Didn't force my self to learn the unity library here https://docs.unity3d.com/Manual/index.html All of those scripts get stuck in your head the more you use them, after a while not having to check the manual for syntax.

Went from the simplest of stuff, like moving a sphere left right, to more advanced stuff.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by dpoly · Feb 22, 2017 at 04:22 AM

You learn C# by writing C# to solve programming problems. It's easier to start outside Unity, using plain Visual Studio Express. Lots of tutorials, I can't recommend one, but do 10 or 20 or more. Then on to Project Euler. Avoid UI or database, that's not what you need for games.

The coding needs to be simple and natural so you can concentrate on the actual hard parts of your game.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by UnityCoach · Feb 22, 2017 at 07:01 PM

Just like with foreign languages, the language is one thing, the subject another. You can be fluent in a language and yet miss the vocabulary to talk about a given topic.

In regards to C# in Unity VS C# for apps, the main difference between apps and video games, is that an app can have the user wait (you know, the spinning wheel thing), while a game should never go below a target frame rate, usually 60. In Unity, like in most game engines, there's a main loop, that'll update the game world and refresh the screen. This is the message that every component receive when the implement an Update () method. When things take longer than a frame to do (ie: things like downloading extra content or loading a level), we use coroutines to split a process across several frames.

Now, with Unity like with any other API based environment, you never know every thing about it. You rely on the documentation. At the beginning of a script, there are some "using". They explicitly tell the compiler which assembly the class you declare will rely on. Like using UnityEngine for everything Unity, and using UnityEditor for everything Unity Editor related. You can add more, like using UnityEngine.UI to implement some UI stuff, or using System.Collections.Generic to use generic list and dictionaries, or other System assemblies.

I personally learnt using Unity documentation along with C# Programming Guide from MSDN, and with a great mentor too, who taught me a great deal on object oriented programming. Though, there are also design patterns that apply to apps more than games, and somehow go against the component approach suggested (and only suggested) by Unity. What you may find a little difficult to grasp, is that some words are keywords, like public, private, static, protected, sealed, abstract, interface, etc, while some others are just ideas, like generic, singleton, instance, factory, model-view-controller, etc.

So, what's important as you progress is to fully understand what's behind the syntax, like :

 transform.position = Vector3.Lerp(transform.position, targPos, Time.deltaTime * speed);

transform is a shorthand to access the Transform component on the same GameObject. .position is the world position property of the transform component, it's of type Vector3 Vector3 is a variable type, it belongs to UnityEngine types can implement methods Vector3 offers a Lerp (Linear Interpolation) method that takes 3 arguments ; from, to and interpolation level, here it's given the position of the object, another position, and an interpolation state that uses Time.deltaTime multiplied by a speed value Time is a class of UnityEngine that tells everything about time in the game and .deltaTime is how much time has elapsed since last Update. Although this is pretty popular technique, it's not the way Lerp is meant to be used, as with this implementation, the object will almost never reach the target, it's like dividing any number by 2, no matter how many times you divide, there's always something left. But that's another story :)

Check out my youtube channel for some free videos, and if you're interested, here's a complete training course I put together on programming with Unity.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

319 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

IAP function not calling 0 Answers

In Game Programming Language 1 Answer

How to make a surface glow when its hit by a laser. 0 Answers

How to save Position data in other variables 0 Answers

in the Lego Micro game, where can i find the parameters for the grid and bricks?,where in the lego micro game do they reference/ establish the grid and the properties of the bricks? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges