Unit Movement

Project: Armament
Role: Game Programmer
Completed: 119.03 Cpl Wallace Donegan Game Programmer
Start Date: 3/12/2018 22:42
End Date: 3/26/2018 15:18
Objective
We want a class to control unit and units selection and movement of that unit.
  • Left click select then move
  • Left click drag and highlight units then left click again and move units
Must use a navmesh and units must not run into each other

Do this in the sandbox folder first
Unit Movement

Assets
No Public Asset Available

Complete Task
5.00 HR.
Ok, I'm turning this in for completion. The only part of the agenda I haven't finished that I am working on is highlighting units. So far I have unit selection working, the movement working, and the object avoidance working. 

For debug purposes, Left Click will set the destination of an IMovable object if any are selected. Right-Click will select the clicked IMovable unit or clear the selected units if clicking on the empty terrain. Right-Click-Drag will form a selection box that blankets the terrain adds the objects in its bounds to the selectedIMovable list. 

When I switched to Jonathan's terrain and mapped to the hight of the terrain everything went smoothly. I did notice when selecting an extremely large area the mesh folds in on itself. It should be something we can work around for now while I figure out the problem and limit the selectable area so this isn't an issue. If it does become an issue we can attack that problem at that time. I've setup fall back options that should be quick to implement just in case. 

Links Below:

Unit Selection working in the scene.

RTS Selection tutorial.


Liaison

I already have movement and unit avoidance for a single unit. I will work on unit selection, and group selection mechanics next in order to complete this task. 


@Wallace Anthony found a sample project he listed earlier in another forum called "ATerribleKingdom-master" this would be really good place to take thing if you have not already.

ATerribleKingdom-master

Thanks,
James Fleming 
Facebook
Discord


Ok, I'll look into it. I'm trying to slow myself down but I've had a lot of time on my hands and have been enjoying tackling these problems. Even if the majority of the things I've come up with are not used I'm learning from it and testing ideas. Trying a lot of things leads to a lot of good and bad ideas after all. 


@Wallace I'm glad your having fun really nice to hear that from our group.


I haven't gotten a chance to log any time but I have been working on this. As part of my previous workflow, I have created a NavMesh and an Agent to use. I have it moving and working, as I've shown. At this point in the agenda, I'm creating a GameObject in the scene called SelectionManager, with a SelectionManager script. This will handle the Vectors storing which units are selected. I'm going to create a sort of base class that will have information about an object that will be stored it the vectors. This should eventually work with an order system to issue commands that are context-based when multiple types of units with different default actions are selected. 


It sounds like the right direction.  The way I see this working is that when code is checked into the sandbox area under your name Anthony or I will parse it out into the project to follow our pattern for the code design.  Once we have this really nailed down then we can have meeting and discuss any fine details we need to work out.  I honestly have not had the time so far to dive into it yet as I been working on like 5000 other thing for the game. :( I just want to code :(:(

I will have time this weekend and see what I can get done.

Thanks,
James Fleming 
Facebook
Discord


I know the feeling. When coding I'm solving problems I can solve, not thinking about the problems I can't. 


Just a quick preview. I have the logic for click-drag selection areas being visualized with debug rays and lines. So far the corners conform to the terrain height. I'll work on it more tomorrow when I get home.
work on selection mechanics


Another update. I haven't had a lot of time to work on this since the last update but I have managed to do some to generate a selection field (with debug visibility only at this point).

Selection Grid visual in debug mode


That looks cool when do you think this will be completed so I can play with it :)?


Well, I think I'm a total amateur because I keep getting caught following the rabbit hole. I know how I want to approach moving units as a group. At the moment I'm creating the mechanism to select units that are on the map though. Its basically a separate task but I'm so far into it now there is no point not finishing it. I'm doing the final logic that will generate the mesh that will be used as a collider and as a mesh for a texture if so desired to visualize the section area.

If a texture a 9-slice image with mostly an alpha fill with a border or some kind. Or if we add subtle variations to the mesh vertices heights and apply an alpha texture to give it a transparent low poly look. 

I'm trying not to worry about how it looks and just build the collider, then add the functionality to add units and remove them from a list which can then be issued orders.

I'm doing my best to focus on just functionality and not aesthetics. Using debug rays and lines as much as I can to visualize what I'm doing. I'll do a Check-In this afternoon so you can start playing with it now because it will probably take me the weekend to finish everything. 


I'm checking-in the project now. Ive not finished I'm having some issues building my mesh. I need to clean up the logic a bit but it almost finished. I'm in the process of adding the selected unit functionality at the same time. 



Excellent we will have the GUI done soon as well.


I've figured out the problem with the large selection area folding in on itself. There is a hard limit of 65xxx vertices a mesh can contain. Becuase I haven't yet implemented a LOD on the mesh there is a vertex at every Unity unit (1 meter) this is something I need to address. I will set up a detail setting we can adjust in the editor that will spread the vertices out more so we can mesh a larger area. Ideally, some research into tessellation would be great here so large consistent areas can have fewer vertices than a very rugged or sharp area that needs more detail. 

I feel like I've done good squeezing the performance I have out of this being as though it is building the mesh and raycasting every vertice every frame that the user is dragging the mouse. There is a lot of room for optimization though.


Can we get and action list for what needs to be done for this or could be done in a list form so we can set up agendas?

Thanks,
James Fleming 
Facebook
Discord


I just logged back on actually to request an agenda be made. I'm working on the selection highlight and I'm almost finished. One of the things I need to do though in order to keep the code performant is creating an object pool. I wanted to ask if that could be a separate agenda. To create a generic object pooler that we can use with any object in the game. I've done this before and have a basic shell in one of my personal projects that I would like to scale up and implement.

So in List form:

1. Object pooler that is generic and reusable.

2. Lod System for selection mesh, take a day or two to implement and leads to immediate performance gains and increased selection size. (can currently select about a quarter of the map without glitches.)

3. Mesh Tesslialltion - could lead to drastic performance improvements. (I am into learning how but have no idea at the moment.) This isn't LOD tessellation either; how close that camera is wont matter, in this sense we are increasing detail in areas where a larger face wouldn't conform to the terrain surface. 

3. Selection script updates. This is for once we get the unit base classes set up and add an ISelectable interface. At that point, we will want to revisit how the selector finds and stores the selected units. Basically needs to start handling multiple unit types, adjusting the selection highlights to fit the selected object, things like that.

I already started a new task for the basic unit info, but I'm going to work on the object pooler as well so I can finish the selection highlights ( having trouble properly Instantiating the highlight and prefer to use a pooler as the Instantiate method is very heavy performance wise anyway.)


I just logged back on actually to request an agenda be made. I'm working on the selection highlight and I'm almost finished. One of the things I need to do though in order to keep the code performant is creating an object pool. I wanted to ask if that could be a separate agenda. To create a generic object pooler that we can use with any object in the game. I've done this before and have a basic shell in one of my personal projects that I would like to scale up and implement.

So in List form:

1. Object pooler that is generic and reusable.

2. Lod System for selection mesh, take a day or two to implement and leads to immediate performance gains and increased selection size. (can currently select about a quarter of the map without glitches.)

3. Mesh Tesslialltion - could lead to drastic performance improvements. (I am into learning how but have no idea at the moment.) This isn't LOD tessellation either; how close that camera is wont matter, in this sense we are increasing detail in areas where a larger face wouldn't conform to the terrain surface. 

3. Selection script updates. This is for once we get the unit base classes set up and add an ISelectable interface. At that point, we will want to revisit how the selector finds and stores the selected units. Basically needs to start handling multiple unit types, adjusting the selection highlights to fit the selected object, things like that.

I already started a new task for the basic unit info, but I'm going to work on the object pooler as well so I can finish the selection highlights ( having trouble properly Instantiating the highlight and prefer to use a pooler as the Instantiate method is very heavy performance wise anyway.)


The selection highlight in action and working. Its just attached to the unit itself and activated and deactivated as needed.


So I didn't realize it but a simple mistake led to an interesting effect. The selection mesh literally blankets the units as well... kinda cool, potentially. Its an easy fix but it prevents the mesh from bisecting the unit. This is one of the things that will lose its effect once I've increased the mesh size to be less dense.

Un-intended effects


@Wallace That is interested look a bit funny lol.  Thank you for the list we will get it setup as soon as possible.

@Anthony Can you take Wallace list and make agenda based off them as you see fit please.

Thanks,
James Fleming 
Facebook
Discord


@Wallace What files go to this agenda in the project?  I don't see an agenda Id folder for which one was this.

538.05 SSgt Lead Anthony Michelizzi

I dragged and dropped his whole Sandbox folder in, but I didn't get a chance to look for the prefabs, so that's what we will need is what prefabs were made for this.

Sorry to drop the ball on this @team, It's been a hectic couple of days with travel.



 When I get a chance today I will go through and create a separate folder for each agenda... Those files will not be attached to my working scene nor will the original files be moved as it would break the scene and stop it from functioning. 


I'm trying to check in with MCU and having no success. I've purged and reset everything but it keeps freezing. I've let it sit there and windows will eventually close the program. 


MCU isn't working for me at the moment, its possible it is my internet. I apologize for doing this here perhaps you can move or delete it but this is my sandbox folder with the updated agenda folders. I wasn't able to edit the time logged area to upload this not sure where else to do it. 


538.05 SSgt Lead Anthony Michelizzi

I added an agenda for the Pooler script. I would like to steer away from anything to do with selection for the mean time until after I get back from my trip and I get a chance to dig into the scripts and get a working demo of what we have.

I fly out tomorrow, Thursday the 28th at around 8am EST and back home around 6pm EST. I probably won't have the chance to get anything done then, but I will do what I can on Friday.



OK, not a problem. I need to try to meet with James today about MCU. I wiped everything reinstalled, pulled latest, updated my folder, check-it... (all this took like 2-3 hours mind you) still isn't removing the folders that were deleted and moved so there are probably double copies everywhere now. 


MCU does not have the ability to delete files