Search Unity

Official Lynda RTS tutorial review/Q&A.

Discussion in 'Community Learning & Teaching' started by DanVioletSagmiller, May 2, 2016.

  1. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    theANMATOR2b likes this.
  2. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    are you able to post to Pluralsight too? :)
     
    DanVioletSagmiller likes this.
  3. Coach_Robi

    Coach_Robi

    Joined:
    May 4, 2015
    Posts:
    3
    I am going to check this out! Thanks for sharing the info about it!
     
    DanVioletSagmiller likes this.
  4. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    @tswalk saddly, I cannot post the same content on the pluralsight and lynda.com, Though I am planning on Udemy next.
     
  5. moffata2

    moffata2

    Joined:
    Jun 17, 2015
    Posts:
    25
    Hi Dan,

    Great tutorial! Joined Lynda just for it! How would you implement a drag box select and double click (select all similar units in view) for the units?

    Warm regards,
    Tony
     
    DanVioletSagmiller likes this.
  6. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    I would probably use a cube, setting one corner where I clicked initially, and another corner following the mouse. The cube would be a trigger, and transparent (like 80%).

    The cube's size would be something like Z = 10(make it designer editable), x = distance between x1/x2, y = distance between y1/y2. Place the cube at ((Point1 + Point2) / 2) (between the two mouse points)

    Finally, selection would be every unit in the bounding box.

    I would setup a reaction event to refresh this every 0.1-0.2 seconds, so I'm not spending too much of the cycles marking which characters are selected.

    Another option would be to use a bordered empty UI image to mark with, and after translating screen to world coordinates, gather all the units with X and Y in the rect.

    The second is probably the less expensive option, but the first would probably have some interesting visuals.
     
  7. moffata2

    moffata2

    Joined:
    Jun 17, 2015
    Posts:
    25
    Thanks Dan,

    Will give it a go!

    Warm regards,
    Tony
     
  8. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    nice tutorials Dan but realy missed one thing it doesn't have multiple unit selection with mouse drag which is one of main bone of RTS games since selecting one by one one unit is realy hard :/
     
    DanVioletSagmiller likes this.
  9. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    @Jenifer_Jane I agree. Their are a hundred extra things I would like to have added, but I had to make choices to keep the time down. I think that is the weakest part of playing the game right now, and the 2nd would be the lack of ability to click on the mini map to move the view.

    I tried to give a starter for most of the sections, something to get you going, but I had to leave them minimal. Polishing the work could have easily tripled the time. Even if I did resolve those 2 things in the class, other things would have likely felt just as important.

    However, perhaps I could post some extension video's on my upcoming Unity/WebGL blog. Some things to clean it up a bit. I'm a bit busy and might not be able to get to it July/August.
     
  10. Kalmak

    Kalmak

    Joined:
    Nov 15, 2008
    Posts:
    52
    DanVioletSagmiller likes this.
  11. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    ok thnx

    thnx will give it a try ^^
     
  12. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
  13. Jeryl

    Jeryl

    Joined:
    Sep 18, 2015
    Posts:
    45
    Hi, I've followed the tutorial and everything works up until the building placement. No matter where my ghost building is, it stays red. I even deleted my terrain and replaced it by an empty terrain with no other objects. I've checked for typos or forgotten things in the code, but all appears to be as in your tutorial so I don't really know what's wrong. I've tried with a unity cube and a custom mesh.
    Any idea what could cause the issue?
    Thanks
     
  14. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    Sorry to hear you're running into an issue. Its been a while since I've looked at it, but I have a couple ideas.

    1) The object is supposed to be high enough that it doesn't overlap the ground. I.e. a cube starts from the center, so half of it would be colliding with the ground. You could be running into the same issue with a model.
    - Make sure your center point is at the bottom of the model. Or even instantiate it a little (just a little) higher than expected.

    2) When creating the video series, I ran into a bug that broke my code for several days while I pulled my hair out trying to figure out why it failed and worked before. Turned out, in the code that checks for over lap, I wasn't excluding the transparent version of the object. I.e. I'm using a building as a cursor, and then checking to see if it overlapped with any other object in the scene. So every time it checked, it caught that it's own model overlapped with itself.
    - Check to make sure your overlap testing code tests if your cursor building is the building it compares against. If it is, it should run a "continue;" in the loop to skip it. one tiny missing line breaks everything. :)
     
    Last edited: Feb 13, 2017
  15. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    I think I'm recalling that 1 would not be an issue. I think it took each vertice in the model and made sure that point didn't collide with another object, but that it is a fraction higher than the ground for collision testing. Assuming I'm right in my recollection at the moment, then #2 is most likely the correct problem.

    If you are still having trouble, I would put a debug point in the code. to check for it.

    I know debugging where a 3D point intersects with others, can be difficult in VS, as it only shows you the problem in the code and you can't visualize it at the same time. Here is a trick. Create a game object with some transparent object in it. Something to help pin point 3D space. Then create a class like this:
    public class Debug3dPoint : MonoBehaviour
    {
    public static Vector3 At = Vector3.Zero;
    public void Update()
    {
    transform.position = At;​
    }​
    }
    // code might have a typo. I just entered it off the top of my head​
    The whole point is that this 1 test object will show up anywhere that you say Debug3dPoint.At = [target 3D position]; Once you have this object in your scene and enabled. In the code that checks for overlap, have it say Debug3DPoint.At = checkPosition; (or whatever the vector 3 variable name was it was checking).

    When running the scene, you will see this constantly showing where in the scene it was failing. if you can't see it, pause the scene (Ctrl/Cmd+Shift+P) and look for it through the hierarchy. (Or if it is succeeding, it will still show up, but only in the last place you tested.)

    Since the overlap functionality returns a false as soon as it finds something, that test object will now point to the exact spot that is causing it to return false. :)
     
    Last edited: Feb 13, 2017
  16. Jeryl

    Jeryl

    Joined:
    Sep 18, 2015
    Posts:
    45
    Hey, thanks for the answer. The 3d debug trick will be pretty useful! My problem wasn't actually code related (or I think). I noticed that I cleared the NavMesh so I tried to rebake it and the prefab became green ! So just me being a noob I guess :)
    That raises another question though which will probably be useful to others. The building placing depends on the NavMesh. My project is more of a city-builder (caesar more than simcity) but this tuto is still useful to me (especially the building placement since it is 50% of the game). My problem is that the terrain I use is not flat. Obviously, the player shouldn't be able to build on mountains but since my terrain has small hills, most of the time, the prefab turns red. Is there a way to allow parts of the mesh to be under the terrain if most of it in over it?
     
  17. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    I had designed a solution to this a while back. Where you want things to build on hills for instance. Here was the trick I used. When dragging the building around, check all the X/Z points to see what the highest terrain point is.


    Then your model must have a "basement". I.e. this can literally be a concrete texture block that is part of your building model. The highest point of the terrain is where your actual building starts. The lowest point on the terrain must not be shorter than your basement. The basement will be seen supporting it.

    (You could also just place your building height at the highest terrain point, then place a cube underneath with the basement texture, stretched to fit any height. You could expand use the cubic units of space that block takes to increase the building cost, allowing you to build in steeper places, but making it more expensive. :) )

    Now if you have units exiting a building, then this doesn't make as much sense. You'd have to add extra code to make sure the building has a valid exit point. I.e. tanks aren't going to roll out and take a 20 foot plunge. :)

    It runs on the same principal of free placement.
     
    Last edited: Feb 16, 2017
  18. Jeryl

    Jeryl

    Joined:
    Sep 18, 2015
    Posts:
    45
    Ok, thanks for taking the time. I'll think about the basement idea, i'll probably adapt it and use it ;)
     
  19. Ventessel

    Ventessel

    Joined:
    Feb 17, 2017
    Posts:
    1
    Hi Dan, great tutorial thus far but I am running into a slight issue that I believe may be related to the NavMesh. When new units are created in the command base, they stay locked inside the building and aren't pushed out by the colliders.

    The drones have sphere colliders and the base has a box collider, I've pretty much followed the tutorial to the letter up to Chapter 9, and there don't appear to be any typos or bugs.

    Any idea why this might not be working properly? Should I perhaps instantiate the newly created drones with an offset from the base?

    EDIT: Nevermind, I refreshed the reference to the Drone unit prefab in CreateUnitAction.cs inside Unity and it started working properly.
     
    Last edited: Mar 2, 2017
  20. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    Awesome! I'm glad that resolved itself! (I had a few suggestions in mind when reading it, but they were not the solution you found.)
     
  21. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    Anyone here is welcome to connect to me on LinkedIn (Dan Violet Sagmiller), or on my blog (still under construction) at http://OurSdc.com. I'm planning on hosting a lot of C#/Unity/WebGL examples up there.
     
  22. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Just came across your R.T.S Course and as I wish to do a Battlezone 3D R.T.S style game I think this would be most useful Hopefully I can learn how to have multiple camera's and how to click on a bitmap or sprite (telescreen) to operate the typical R.TS Camera Thank you One thing can people still download the tutorial files?
     
  23. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    yes. Though I believe they are for Unity 5.6.
     
  24. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK where can I download them please? As I can't seem to download them from LinkedIn
     
  25. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    204
    There is a tab called Excercise files under the video. It may be a feature of LinkedIn Premium. If you don't have access, the same thing is on Lynda.com, and you can use a trial pass to get the files.
     
  26. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK Thank you Oh I sent some questions in to you via LinkedIn by the way Thanks