Search Unity

What do i need to be a game programmer?

Discussion in 'General Discussion' started by BrunoPuccio, Jun 11, 2018.

  1. BrunoPuccio

    BrunoPuccio

    Joined:
    Dec 13, 2017
    Posts:
    22
    what kind of skills and knowledge do i need to be a game programmer and work for a games company?

    i have been studying programming for almost two years and learnt about OOP, web and databases. i also made some little projects in unity, some of them were using uNet. i even made some plugins for a game called Rust(i love this game) but i still feel that i don't know anything.

    i don't want to make a game of my own, i want to be a programmer. I know i still have a lot to learn but i don't know what to learn next

    Edit: i am currently reading this book
    Mathematics for 3D Game Programming and Computer Graphics
     
    Last edited: Jun 11, 2018
  2. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    imo its 'doing', nothing beats firing up unity and whipping through their tuts.
     
  3. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    577
    It's all different depending on the company. Some use special in house engines, some use Unreal, some use Unity.
     
    JamesArndt likes this.
  4. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    Make some games, build a portfolio and start applying, you won't know if you are ready till you get a job.
     
    angrypenguin likes this.
  5. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Technical skills are great, but I also find communication and design skills are very useful for programmers to have too.

    But I think good programming skills, a passion for games and a willingness to work long hours :( will get you into most bigger games companies.
     
    JamesArndt and Deleted User like this.
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Best way to figure out what you need is to actually start applying for jobs. Look and see what skills are listed on the job adverts. Go the the interviews and see what they are asking for. You will quickly get a sense of whats needed.
     
    Deleted User likes this.
  7. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181

    Nobody cares what you feel. :)

    What they care about is what skills you can bring to the team/project. Will you help get the thing finished and done right? Like already mentioned, start applying and talking to people in the business. Find out what they need. If you have the skills already, awesome. If not, you learn them. When you are ignorant, how could you not feel insecure? When you have knowledge, there is no reason not to be confident.
     
    angrypenguin and Kiwasi like this.
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,147
    You're going to have to make a game of your own and/or make enough of an impression on people that they will offer you the chance at working on a project. Basically you need to prove that you have the knowledge to make a game and that you can stick with it every step of the way. Creating and releasing a game is the best and most commonly looked for approach.
     
  9. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Great. I'm constantly surprised at the number of people who work on games but don't understand things like common vector operations.
     
    ModLunar and passerbycmc like this.
  10. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    This, it will help you a lot, even just having enough of a understanding to know where to look and what terms to use.
     
    ModLunar likes this.
  11. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    How frequently do you use that kind of stuff though? I've never used my high-level math knowledge in game dev.

    Edit: I guess I've considered the use of n-dimensional vectors for one of my games along with pathfinding between them, but that just seems like one of several ways to do a job, with the other ways to get at the final solution not relying on such things.
     
    Last edited: Jun 12, 2018
  12. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778

    I use matrices (4x4 vector), vectors(3x1), quaternions. Just yesterday I used integration for business purposes and I often use linear equations to work out things like trajectories.

    There's also a lot of other useful stuff like, plane intersections, line intersections, etc... maths it king!
     
    ModLunar likes this.
  13. Deleted User

    Deleted User

    Guest

    I would recommend some proficiency with algebra, trigonometry, some calculus, discrete mathematics, and data structures & algorithms (those three words with the '&' are one topic)...

    That's just my opinion. And it the beginnings of being a computer scientist too. You will probably struggle with DS and Algorithms without at least some knowledge of calculus & discrete math though. Employers in pretty much anything software engineering are going to want knowledge of data structures & algorithms especially, I've not had an interview without that kind of material being covered.
     
  14. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I use that stuff all the time.

    How do I point X towards Y? How do I move X away from / towards Y? How do I get X to orbit / move around Y? How do I align my object with the slope it is sliding down? How do I calculate the velocity an object is moving at? What position do I put X in so that it is at Y position in relation to Z?

    And that's without even getting to physics. What force to I apply to X to get... insert desired result here?

    To be clear, Unity provides plenty of math functions so I don't often have to use the equations myself. But sometimes I do, and even without that, understanding how the numbers work and what the relationships and operations are is just ridiculously helpful.
     
    ModLunar, Ch33ri0s, AxPetre and 3 others like this.
  15. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I'm a chemical engineer. I did ridiculous amounts of higher mathematics to get qualified. I don't use much of it in my day job. Somewhat ironically, its become super useful as a foundation for game development.
     
    ModLunar and neoshaman like this.
  16. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    As a bedroom coder I wish I had a proper education on data structure, even though they are just a google away, I feel painfully slow dealing with them, especially when sorting is involved. But vector is everything, I'm always joking about how you can solve anything with dot product ...
    Brb I have a convex hull to implement ...
     
  17. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    I guess I've just had less experience (with game dev) than the rest of you. I've certainly used math for non-game-programming (was working with group theory a month or so back), maybe I'll wind up using it eventually for games.
     
  18. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    It really depends on the type of stuff you're doing. For many types of games the built-in tools are all you need, especially if you can rely on placing things in the editor and/or using animation tools for getting things where you want them. The math for all of that is done for you.

    It's when you have code that has to move things around in complex ways, or operate on geometry, or a lot of graphics stuff such as how light interacts with surfaces...

    The good news is that, at least for me, all of that stuff suddenly is easier and makes sense when you're using it for something practical, where the numbers have a tangible meaning. When I did this same stuff in high school and it was all just abstract numbers I found it ridiculously hard to understand.
     
    BrunoPuccio, ModLunar, Kiwasi and 3 others like this.
  19. Deleted User

    Deleted User

    Guest

    Consider it like a doorway. Most people think that the pythagorean theorem is absolutely useless in everyday life. Or at least that was the attitude when I was in high school. You don't understand but its used absolutely everywhere and in everything. True it's not going to help you calculate the best value per pound at the grocery store but it will open up new avenues of problem solving and ways of thinking.

    TBPH I started this degree program (Comp Sci) three years ago thinking it was going to be a bunch of programming. I was sort of disappointed to figure out halfway through that it wasn't, and that is my fault but it turned out to be a delightful blessing. I may not readily pick up a math or physics textbook to read every day but when I do its a moderate read, and quite fascinating. Also CS is about more than just programming or math. Its about having computers solve problems efficiently and correctly among others.

    My freshman year I purchased a physics for dummies book. I read part way through and got bored. Fast forward 3 years and I thoroughly understand why those concepts like average velocity and moment of inertia are important, and I still haven't taken a physics course.

    Also Wikipedia will be so much easier to read if you have a decent math background. My personal beef with that website is its touted as a repository of information, too bad nobody but someone with a university level of education can easily comprehend whats been written. UGH.

    If nothing else go online and look up data structures and algorithms on YouTube or somewhere else. Data Structures are just methods of efficient storage and organization of data, and algorithms (aka methods computers use to solve problems) to retrieve and manipulate that data.

    Also if you are halfway decent at coding, I think you will find algorithms pretty straightforward (maybe not the math). They are just carefully designed methods to solve particular problems with a computer.

    I must mention I am taking a math minor too, I'm kind of a nut XD
     
    Last edited by a moderator: Jun 13, 2018
    ModLunar and angrypenguin like this.
  20. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Where do you guys end up actually using math?

    And what exactly do we consider "math"? Like
    (destination - origin)
    isn't really "math"...or is it?

    In my experience, geometry ends up being used a ton in procedural generation and camera work. But outside of that it's pretty rare.
     
    EternalAmbiguity likes this.
  21. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Not in VR, we use alot of geometry for alot of our stuff. Since many actions are movement based
     
  22. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Can you give material examples?
     
  23. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    What else is it?
     
    Kiwasi likes this.
  24. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Sure here is a really simple example, we have more extreme uses of geometry offcourse, HK Slap


    Code
    Code (CSharp):
    1.         public void OnCollide(NVRHand hand, Collision col)
    2.         {
    3.             if(IsLockedBack)
    4.             {
    5.                 var force = Vector3.Project(col.relativeVelocity, SlamDirection.up);
    6.  
    7.                 var angle = Vector3.Angle(SlamDirection.up, col.relativeVelocity);
    8.  
    9.                 if (angle < 60 && force.magnitude > 0.25f)
    10.                 {
    11.                     ReturnSlide();
    12.                     hand.ForceGhost();
    13.                 }            
    14.             }
    15.         }
    If you dont understand the math behind Project, Dot, etc, it will be a pain and take really long time to get anywhere if you need this kind of mechanics
     
    iamthwee and frosted like this.
  25. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Perhaps it's sloppy thinking on my part, but I tend to think of most simple math as more akin to logic than "math". But I guess "simple" is pretty subjective, a lot of people don't even really understand what lerp does.

    That makes sense. I can see how processing the input would require geometry, since you need to interpret motion.
     
  26. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Well (destination - origin) is not (origin - destination) you are creating a vector with a proper direction, just knowing that will solve 99% problem noob tend to have. And let's be frank, I'm doing a lot of vector math now and that's basically just that, complex stuff is just a bunch of simple stuff in the right order:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class convexTest : MonoBehaviour {
    6.     Vector3[] vertlist;
    7.     Vector3 centroid;
    8.     ArrayList discard;
    9.     List<Vector3> SupportVert;
    10.     List<Vector3> convexPoints;
    11.     Vector3
    12.         minX,maxX,
    13.         minY,maxY,
    14.         minZ,maxZ;
    15.     Mesh convexMesh;
    16.     mesh2Hedges hull;
    17.  
    18.     //*********************************************************
    19.     void Start () {
    20.         this.vertlist = new Vector3[100];
    21.         this.discard = new ArrayList();
    22.         this.SupportVert = new List<Vector3>();
    23.         this.convexPoints = new List<Vector3>();
    24.         for(int i =0; i< this.vertlist.Length;i++){
    25.             this.vertlist[i] = Random.insideUnitSphere;
    26.             this.SupportVert.Add( this.vertlist[i]);}
    27.         findSupportVert();
    28.         FindExtremum();
    29.         //showdebugresult();
    30.         selectExtremum();
    31.         FindTriangle();
    32.         FindTetra();
    33.         //drawDebugTetra();
    34.         buildMesh();
    35.         toHalfEdge();
    36.      
    37.         Debug.Break();}
    38.      
    39.     //*********************************************************
    40.  
    41.     void findSupportVert () {
    42.         //compute centroid position
    43.         foreach (Vector3 v in this.vertlist){this.centroid += v;}
    44.         this.centroid /= this.vertlist.Length;
    45.         //initialize loop
    46.         Vector3 support = new Vector3();
    47.         float max = float.Epsilon;
    48.         //iterate points to get the support point
    49.         foreach (Vector3 v in this.vertlist){
    50.             Vector3 normalDirection =(v - this.centroid).normalized;//vector= end - start
    51.             //check all other points to find support
    52.             max = float.Epsilon;
    53.             foreach (Vector3 t in this.SupportVert){
    54.                 Vector3 compared= t - this.centroid;
    55.                 float dot = Vector3.Dot (compared,normalDirection);
    56.                 if (dot > max) {
    57.                     max = dot;
    58.                     support = t;}}
    59.             //after iteration, if current is not support, discard
    60.             if (support != v) {this.discard.Add (v);
    61.                 this.SupportVert.Remove(v);}}}
    62.      
    63.     void FindExtremum(){
    64.         this.minX = this.SupportVert[0]; this.maxX = this.SupportVert[0];
    65.         this.minY = this.SupportVert[0]; this.maxY = this.SupportVert[0];
    66.         this.minZ = this.SupportVert[0]; this.maxZ = this.SupportVert[0];
    67.         foreach (Vector3 v in this.SupportVert){
    68.             if (v.x > this.maxX.x) this.maxX = v; if (v.x < this.minX.x) this.minX = v;
    69.             if (v.y > this.maxY.y) this.maxY = v; if (v.y < this.minY.y) this.minY = v;
    70.             if (v.z > this.maxZ.z) this.maxZ = v; if (v.z < this.minZ.z) this.minZ = v;}}
    71.      
    72.     void showdebugresult(){
    73.         foreach (Vector3 v in this.SupportVert){
    74.             //Debug.DrawLine(this.centroid, v, Color.white);
    75.         }
    76.         foreach (Vector3 v in this.discard){
    77.             //Debug.DrawLine(this.centroid, v, Color.red);
    78.         }
    79.         DrawDebugCube(this.minX,Color.cyan); DrawDebugCube(this.maxX,Color.yellow);
    80.         DrawDebugCube(this.minY,Color.black);DrawDebugCube(this.maxY,Color.gray);
    81.         DrawDebugCube(this.minZ,Color.green);DrawDebugCube(this.maxZ,Color.blue);}
    82.      
    83.     void DrawDebugCube(Vector3 pos, Color color){
    84.         float size = 0.1f;
    85.         Vector3 up        = pos + Vector3.up        *size;    Vector3 down    = pos + Vector3.down    *size;
    86.         Vector3 right    = pos + Vector3.right    *size;    Vector3 left    = pos + Vector3.left    *size;
    87.         Vector3 forward    = pos + Vector3.forward    *size;    Vector3 back    = pos + Vector3.back    *size;
    88.         Debug.DrawLine(up,down,        color);
    89.         Debug.DrawLine(right,left,    color);
    90.         Debug.DrawLine(forward,back,color);
    91.     }
    92.      
    93.     void selectExtremum(){
    94.         Vector3[] extremumlist = new Vector3[6];
    95.         Vector3[,] size = new Vector3[6,6];
    96.         Vector3 biggest = Vector3.zero;int bx=0,by=0;
    97.         extremumlist[0] = this.minX; extremumlist[1] = this.maxX;
    98.         extremumlist[2] = this.minY; extremumlist[3] = this.maxY;
    99.         extremumlist[4] = this.minZ; extremumlist[5] = this.maxZ;
    100.         //loop all size combination for curiosity, should just take each extrem pair only really
    101.         for (int i = 0; i < extremumlist.Length; i++) {
    102.             for (int j = 0; j <  extremumlist.Length; j++) {
    103.                 if (extremumlist[i] == extremumlist[j]) continue;
    104.                 size[i,j] = extremumlist[i]- extremumlist[j];}}
    105.         //loop to find the biggest
    106.         for (int i = 0; i < size.Length; i++) {
    107.             int ax = i/6, ay = i%6;
    108.             if (ax == ay) continue;
    109.             if (size[ax,ay].sqrMagnitude > biggest.sqrMagnitude){ biggest = size[ax,ay]; bx = ax; by = ay;}}
    110.         this.convexPoints.Add(extremumlist[bx]);
    111.         this.convexPoints.Add(extremumlist[by]);
    112.     }
    113.      
    114.     void FindTriangle(){
    115.         Vector3 furthest = convexPoints[0], projected = Vector3.zero;
    116.         float maxlength = 0;
    117.         foreach (Vector3 v in this.SupportVert){//v is point to measure distance to
    118.             Vector3 ov = v-convexPoints[0];//vector to the point to project
    119.             Vector3 o1 = convexPoints[1]-convexPoints[0];//segment to project onto
    120.             Vector3 p = Vector3.Project(ov,o1.normalized);//resulting projection point on the segment
    121.             Vector3 length = v - p;//length = v-0 + p+o
    122.             float l = length.sqrMagnitude;//should concatenated with above
    123.             if (l > maxlength) {furthest = v;projected = p;maxlength = l;}
    124.          
    125.         }
    126.         this.convexPoints.Add(furthest);
    127.        
    128.     }
    129.      
    130.     void FindTetra(){
    131.         Vector3 furthest = convexPoints[0], projected = Vector3.zero;
    132.         float maxlength = 0;
    133.         Vector3 o1 = convexPoints[1]-convexPoints[0];
    134.         Vector3 o2 = convexPoints[2]-convexPoints[0];
    135.         Vector3 ox = Vector3.Cross(o1,o2);
    136.         foreach (Vector3 v in this.SupportVert){
    137.             Vector3 ov = v-convexPoints[0];    
    138.             Vector3 p = Vector3.ProjectOnPlane(ov,ox);
    139.             Vector3 length = v -(convexPoints[0] + p);
    140.             float l = length.sqrMagnitude;//print(l);
    141.             if (l > maxlength) {furthest = v;projected = p;maxlength = l;}
    142.          
    143.         }
    144.         this.convexPoints.Add(furthest);
    145.      
    146.     }
    147.  
    148.     void drawDebugTetra(){
    149.         Debug.DrawLine(convexPoints[0],convexPoints[1],Color.yellow);
    150.         Debug.DrawLine(convexPoints[0],convexPoints[2],Color.yellow);
    151.         Debug.DrawLine(convexPoints[1],convexPoints[2],Color.yellow);
    152.         Debug.DrawLine(convexPoints[0],convexPoints[3],Color.green);
    153.         Debug.DrawLine(convexPoints[3],convexPoints[2],Color.green);
    154.         Debug.DrawLine(convexPoints[1],convexPoints[3],Color.green);}
    155.  
    156.     void buildMesh(){
    157.         this.convexMesh = new Mesh();
    158.         this.convexMesh.vertices = convexPoints.ToArray();    
    159.         //first find cross product of triangle
    160.         Vector3 o1 = convexPoints[1]-convexPoints[0];
    161.         Vector3 o2 = convexPoints[2]-convexPoints[0];
    162.         Vector3 o3 = convexPoints[3]-convexPoints[0];
    163.         Vector3 ox = Vector3.Cross(o1,o2);
    164.         //check if 4th point is on the same side
    165.         Vector3 p = Vector3.ProjectOnPlane(o3,ox);
    166.         Vector3 p3 = convexPoints[3]-(convexPoints[0] + p);
    167.         float side = Vector3.Dot(ox.normalized,p3.normalized);
    168.         //Debug.DrawLine((convexPoints[0] + p),convexPoints[3],Color.red);
    169.         if (side>0){        //yes -> reverse triangle winding
    170.             this.convexMesh.triangles = new int[]{
    171.                 1,0,2,
    172.                 3,0,1,
    173.                 3,2,0,
    174.                 3,1,2};}
    175.         else{                //no -> triangle winding
    176.             this.convexMesh.triangles = new int[]{
    177.                 0,1,2,
    178.                 0,3,1,
    179.                 2,3,0,
    180.                 1,3,2};}
    181.         if(side == 0) Debug.LogError("degenerate mesh");
    182.         convexMesh.RecalculateNormals();
    183.         this.gameObject.AddComponent<MeshFilter>();
    184.         this.gameObject.GetComponent<MeshFilter>().mesh = convexMesh;
    185.         Material newMaterial = new Material(Shader.Find("Diffuse"));
    186.         this.gameObject.AddComponent<MeshRenderer>();
    187.         this.gameObject.GetComponent<MeshRenderer>().material = newMaterial;}
    188.      
    189.     void toHalfEdge(){
    190.         this.hull = new mesh2Hedges();
    191.         this.hull.UnityMesh = convexMesh;
    192.         this.hull.setup();
    193.         this.hull.DrawDebugHedge();}
    194.  
    195.     class conflictList{
    196.         public mesh2Hedges.half.face triangle;
    197.         public List<Vector3> conflictPoints;
    198.         conflictList(){
    199.             triangle = new mesh2Hedges.half.face();
    200.             conflictPoints = new List<Vector3>();}}
    201.      
    202.     void buildConvex(){
    203.         List<conflictList> conflicts = new List<conflictList>();
    204.      
    205.         //for each face in hull.hface create a conflict list for that face and put it in conflicts
    206.         //->for each point in convexpoint
    207.         //--> for each triangle in hface
    208.         //--> find the facing of the pointo to the face
    209.         //--> if facing: find the distance of the point to face
    210.         //--> if closest face, set face to closest
    211.      
    212.         //-> if cloest face == null, set point to discard list
    213.         //-> else set point to conflict list of closest face
    214.      
    215.      
    216.      
    217.         //for each conflict list
    218.         //-> for each point in conflict list --- while conflict list length > 0
    219.         //--> find distance to face
    220.         //--> if distance bigger than furthest, new point = furthest
    221.      
    222.         //-> for each face in hull
    223.         //--> test furthest facing
    224.         //--> if facing then face set face to seen list
    225.      
    226.         //-> find the horizon of the conflict face
    227.         //--> for each edge of the triangle
    228.         //---> find the next face
    229.         //---> if next face is in process, go next edge, else set next face in processed list
    230.         //---> if next face is in visible, find next face (recursion)
    231.         //---> if next face is not visible, set next face edge in horizon, go next edge
    232.      
    233.         //-> for each edge in horizon
    234.         //--> build triangle with furthest
    235.      
    236.         //-> create new conflict list from point in this conflict list for the new triangle
    237.         //-> delete triangle of the conflict list
    238.         //-> delete the conflict list
    239.      
    240.         //?? no stopping mechanism? check when conflict list is empty ** check when list of conflict is empty
    241.  
    242.      
    243.      
    244.      
    245.      
    246.     }
    247.     //*********************** utils *************************
    248.     float TakePointSqrMagnitude2segment(Vector3 point, Vector3 segmentStart, Vector3 segmentEnd){
    249.         Vector3 ov = point-segmentStart;//vector to the point to project
    250.         Vector3 o1 = segmentEnd-segmentStart;//segment to project onto
    251.         Vector3 p = Vector3.Project(ov,o1.normalized);//resulting projection point on the segment
    252.         return (point - p).sqrMagnitude;//length = v-0 + p+o
    253.     }
    254.     float TakepointSqrMagnitude2triangle(Vector3 point,Vector3 p0, Vector3 p1, Vector3 p2){
    255.         Vector3 o1 = p1-p0;
    256.         Vector3 o2 = p2-p0;
    257.         Vector3 ox = Vector3.Cross(o1,o2);
    258.         Vector3 ov = point-p0;    
    259.         Vector3 p = Vector3.ProjectOnPlane(ov,ox);
    260.         return (point -(p0 + p)).sqrMagnitude;
    261.     }
    262. }
    263.  
    264.  
    Look at how many instance of (destination - origin) I'm having here! I even think I missed some at lines 121 and 252 (can you guess why?), while it work now, seemingly, it might introduce bad behavior down the line, so don't doubt the power of (destination - origin).

    I'm doing the test by being centered at 0,0,0
    But the use case need to be anywhere else,
    the variable p worked because the vector is implicitly originating at 0,0,0
    But I need to offset it from the true origin of the construct

    In fact I had an intuition it was wrong,
    but didn't know why until I wrote it down now :p
    Thanks! I guess
     
    angrypenguin likes this.
  27. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I find that a lot of the time, the hardest thing about mathy bits of code is really remembering what coordinate system youre working in.

    Like, "am I working in local or global space" - "who's perspective am I working with, what is forward?" - etc.

    Subtraction is surprisingly tough because you need to remember what perspective you're working from in order to figure out the ordering.

    (The english translation of direction is also weird, since it's backward to the subtraction: "go from a to b" translates to b-a, so you gotta mentally reverse it or reword it to "reach b from a" which is unnatural)
     
    neoshaman likes this.
  28. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    That's true, behind that little subtraction, there is a surprising amount of mathematical concepts to understand and manipulate, that's the real mathy bit. Those can be hard to learn by profane.
     
    angrypenguin likes this.
  29. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    the tldr version. . . what do you need to be a game programmer?

    certified insane with unusually high/unrealistic goals and a penchant for procrastination.
    Welcome to the family!
     
    Last edited: Jun 13, 2018
    neoshaman likes this.
  30. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Well mathematics is pure distilled logic. So there is that.
     
    AndersMalmgren and angrypenguin like this.
  31. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Math based logic is the difference between a senior and a junior.This i actual code from our game. I'm pretty certain a junior would hav solved this with a bunch of if-blocks, possible nested

    Code (CSharp):
    1.                      
    2.  
    3. var indexRatio = (config.TransitionKeyFrames.Length - 1) * transitionRatio;
    4. var index = (int) indexRatio;
    5. var weight = indexRatio - index;
    6.  
    7. var start = config.TransitionKeyFrames[index];
    8. var target = weight > 0 ? config.TransitionKeyFrames[index + 1] : start;
    9.  
    10. config.Target.position = Vector3.Lerp(start.position, target.position, weight);
    11. config.Target.rotation = Quaternion.Slerp(start.rotation, target.rotation, weight);
    It turns me down I coulldnt solve this line without a if block :D

    Code (CSharp):
    1. var target = weight > 0 ? config.TransitionKeyFrames[index + 1] : start;
    edit: And here the code in action

     
    iamthwee likes this.
  32. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    ^I see you're using the ternary operator, I throughly approve :D
     
  33. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Just a glorified if-block :D But yeah, little better syntax :D
     
  34. Deleted User

    Deleted User

    Guest

    But... its so... ugly!! Haha I use those all the time.
     
  35. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    THIS. Really good people skills are probably more important than the host of technical skills you will bring to the table at an interview. Competency is assumed if you've made it through the phone screen. Once you sit down in that room with folks who want to talk to you they are going to be watching your comfort level, body language, how you communicate complicated principles in an understandable way and how you communicate with others in general. They call these "soft skills" in any industry. I'd say practicing mock interviews to gain a comfort level speaking about what you do and how you go about doing it. As for the programming specifics, you can learn all of that and there are a host of resources to do so. Learn what you think you need to know to target the type of studio you want to work in...i.e. do you want to be a tools programmer and learn Python, etc. What's more important than the specific language and syntax is to be able to solve a problem you're presented with. How would you break a problem down into manageable chunks that you can solve and not only just solve, but solve in a way that is understandable for others and reusable or modular. I've heard this all over our industry and the common theme is, studios need problem solvers. Try to think outside of the box for the definition of a "problem" as well. It can be a barrier to getting something done, it can be a simple task to complete, it can be a bug that needs to be fixed. Languages and syntax are tools in your toolbox when you go out into the world to solve problems for other people. Think of yourself as Mario, going out into the world as a plumber, fixing people's toilets and drains with C# or Python. Okay that last bit was a stretch :)
     
  36. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    You can, your conditional there can be removed without any effect on the code ;)

    Code (csharp):
    1.  
    2. var start = config.TransitionKeyFrames[index];
    3. var target = weight > 0 ? config.TransitionKeyFrames[index + 1] : start;
    4.  
    5. config.Target.position = Vector3.Lerp(start.position, target.position, weight);
    6. config.Target.rotation = Quaternion.Slerp(start.rotation, target.rotation, weight);
    7.  
    If weight <= 0, the lerp will return start anyway. You can remove the conditional.
     
  37. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    @AndersMalmgren - I tend to agree that seniors use fewer conditionals and more math based logic. So if you guys need a senior, feel free to pm me...



    Shots fired!! :D

    (just kidding around - there are plenty of mistakes in my code base too, we're all human at the end of the day.)
     
    iamthwee and AndersMalmgren like this.
  38. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    config.TransitionKeyFrames[index + 1] will be out of bounds
     
    frosted likes this.
  39. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Ouch segment fault!
     
    Last edited: Jun 14, 2018
  40. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    The most important thing I take into consideration, (and IMO all elite programmers should do) when coding is hiding the original purpose from any newbies who might happen to be reading. That's why I try my best of obfuscate it as much as possible.


    Of course on a more serious note.

    I would never use c# or dot net except in unity :D
     
    Last edited: Jun 14, 2018
  41. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I've actually been kind of debating about conditional logic a lot recently. I've realized that in a lot of cases I want a state machine but don't want to use an actual state machine. So I end up with something like this:

    Code (csharp):
    1.  
    2.     protected override void UpdateExecutePhase(){
    3.       var phase = m_ExecutionPhase;
    4.       var type = m_ArgType;
    5.       switch( phase ){
    6.         case ExecutionPhase.Beginning:
    7.           switch( type ){
    8.          
    9.             case ArgType.PathOnly:
    10.               m_ExecutingArg = GetMoveOnlyArgs( m_PreviewArg.PathEnd );
    11.               m_ExecutingArg.Path.AssignPath( Character.AI, this );
    12.               LockSteeringIfLong();
    13.               m_ExecutionPhase = ExecutionPhase.OnPathBegin;
    14.               break;
    15.             case ArgType.PathAndTarget:
    16.               m_ExecutingArg = GetTargetedArgs( m_PreviewArg.TargetCharacter, m_PreviewArg.PathEnd );
    17.               m_ExecutingArg.Path.AssignPath( Character.AI, this );
    18.               LockSteeringIfLong();
    19.               m_ExecutionPhase = ExecutionPhase.OnPathBegin;
    20.               break;
    21.             case ArgType.TargetOnly:
    22.               m_ExecutingArg = GetTargetedArgs( m_PreviewArg.TargetCharacter );
    23.               m_ExecutionPhase = ExecutionPhase.OnActionBegin;
    24.               break;
    25.           }
    26.           break;
    27.         case ExecutionPhase.OnPathBegin:
    28.           BeginExecutePath();
    29.           m_ExecutionPhase = ExecutionPhase.OnPath;
    30.           break;
    31.         case ExecutionPhase.OnPath:
    32.           UpdateExecutePath();
    33.           SceneParts.Get.PlayerPartingBlowManager.DrawPreviewZoC( Character, m_ExecutingArg.Path, m_ExecutingArg.Interrupts );
    34.           if( m_ExecutingArg.HasArrived )
    35.             m_ExecutionPhase = ExecutionPhase.OnPathEnd;
    36.           else if( Character.AI.Destination != m_ExecutingArg.PathEnd ){
    37.          
    38.             Log.Warn( "Cancelled from AI!", this );
    39.             TryCancelExecution();
    40.           }
    41.           break;
    42.         case ExecutionPhase.OnPathEnd:
    43.           BeginPathEnd();
    44.        
    45.           break;
    46.         case ExecutionPhase.OnActionBegin:
    47.           BeginExecuteAction();
    48.           m_ExecutionPhase = ExecutionPhase.OnAction;
    49.           break;
    50.         case ExecutionPhase.OnAction:
    51.           UpdateExecutingAction();
    52.           if( Ability.IsExecutionComplete() )
    53.             m_ExecutionPhase = ExecutionPhase.OnActionEnd;
    54.           break;
    55.         case ExecutionPhase.OnActionEnd:
    56.           m_ExecutionPhase = ExecutionPhase.OnCompleteBegin;
    57.           break;
    58.         case ExecutionPhase.OnCompleteBegin:
    59.           BeginExecuteComplete();
    60.           m_ExecutionPhase = ExecutionPhase.OnComplete;
    61.           break;
    62.         case ExecutionPhase.OnComplete:
    63.           break;
    64.       }
    65.     }
    66.  
    I'm really not sure how to feel about this code. On one hand, I've found it to be pretty easy to work with, on the other hand it doesn't quite sit right. It's just a bootleg state machine.

    There's also plenty of redundant steps I included here just for consistency sake.
     
    iamthwee likes this.
  42. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Beauty is in the eye of the beholder or as I say:

    You say tomato I say pizza
     
  43. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I rewrote the code here, and its not out of bounds

    http://rextester.com/KRAP18976

    Need to revisit this code, I know it went out of bounds
     
  44. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    We use NodeCanvas for this kind of statemachines that are bascily Behaviour trees
     
  45. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    That's what happens when you try to virtually compile the code in your mind. Now I got to go back and edit ma post!
    Thanks a lot!
     
    AndersMalmgren likes this.
  46. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    iamthwee likes this.
  47. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    But is it actually worth it to move away from pure text to mixed mode?

    I mean, admittedly it's a lot of code to achieve the goal - but I donno if it's "bad" exactly. It certainly looks weird, but ...

    Like - we're always flowing in one direction here. Begin, Update, End, then next piece. Only 'flow control' is really potentially skipping one part.
     
  48. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Buddy quit confusing me, I had a long day yesterday.
     
  49. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    I like python:

    Code (CSharp):
    1. a = ['one','shoe','tree']
    2. for summat in a:
    3.     print summat
    ^try and get that badboy outta bounds!
     
  50. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I would atleast try to abstract the state machine code away from the actual code, now its almost more state machien code than there is actual code :D

    But yeah, Its a balance. Our bots have hundreds of conditions going for them so a Behaviour tree fits well for our use case.
     
    angrypenguin and frosted like this.