Help with StrategyGame

Hello Unreal Community,

I’ve got a lot of questions about c++ programming in Unreal Engine regarding my own first steps as well as the StrategyGame example and I would really appreciate it a lot if anyone could take the time to at least respond to a few of my questions. I really wanted to figure it all out on my own but after about two weeks of not understanding the engine at all I decided to ask you guys for help. Below are the questions. I know it’s quite a lot and I understand if you do not want to respond to them in a detailed fashion. It would help if you would respond with one word so I can do the googling. I am really motivated and not lazy so any help is appreciated and I am willing to do the research.

  1. So I’ve got my SpecatorPawn and I want to move my Camera in an RTS style. I bind the function and move it with “AddMovementInput”. Unfortunately this only works after I select the spawned instance of my SpectatorPawn inside the editor. So what I do is I enter playmode and press w for moving forward. Nothing happens with my view but weirdly enough my actors position changes. After I select the SpectatorPawn inside the Editor and then go back into playmode the movement works like intended but it only works with the Input after I reentered. So although my position could be 3000 on an axis, a value like 3300 would only give me the effective location of 300.
    Here (Imgur: The magic of the Internet) you can see two screenshots. The first I zoomed out for like 1 sec and then tabbed out -> selected the pawn. And the second one I was scrolling for like 5 seconds before tabbing out and selecting it. Before selecting the pawn the Viewport view stays at 0/0/0. So I am essentially seeing grey until I select it and then move the camera.

  2. Since I am trying to create an RTS game, do I really need AIController for every single unit?

  3. Is my basic setup viable for an RTS? I am planning on handling Unit selection as well as movement commands inside my SpectatorPawn and having my Units as Pawns without Controllers. Or do I need to handle it inside my PlayerController? I was leaning more towards not handling it inside my PlayerController because I thought that you only need the Unit selection stuff if your SpectatorPawn exists. For every other scene like MainMenu where you do not have the SpectatorPawn you wouldn’t need that.

  4. In Epic’s StrategyExample project you can see stuff like “Team” handled in an interface instead of a variable. What would be the advantage of checking an Actors Interface instead of one of his Variables which might as well contain a team reference?

  5. I am also planning on having a “SelectedUnits” List inside my PlayerController for multiple selection and movement. Is this the best approach?

  6. My attached camera always starts at 0/0/0 world cords. If I move up my playerstart it changes the Actors position but the camera gets a local offset so it ends up being at 0/0/0 again.

I’ve got plenty more questions but I don’t want to be lazy and annoy you all with my stupidity :smiley:

Thank you for your help and excuse my sloppy English (foreigner)

PS: No idea how to
in this forum

Hi Mark,

i can’t answer all of your questions, but here some:

Every single unit needs an AIController. Otherwise your Pawn will be stupid and he cant move. For example: If you have the unit class “A” you only have to program the AI once for this unit class “A”. Every new spawned pawn will have its own instance of this AI you programmed.

I’m also working on a RTS, just for fun. And I’m handling all the stuff inside the PlayerController. A player cant die in a RTS, so i think it doesn’t matter. And as said: Every unit needs a Controller.

Of course you can do it without an interface. But just think about this: What if you have an Actor that responses to your Left-Click-Selection (for example a Tree?) that does not have that variable? You can cast your Actor to you local class, that will work fine. But if you want to access the variable that does not exist you will get a crash (null-pointer or something like that). With implementing the interface you have a clear… yeah, interface between your units. And with the check you get sure, that this unit is actually a unit you are allowed to select or interact with.

I’m handling this that way and it works just fine.

hi,

  1. I made a C++ RTS camera tutorial (extended version of the wiki), you can find it in the forum…
  2. No.
  3. unit selection by mouse can be done easily from PlayerController (select actor under mouse cursor) and HUD (supports actor selection under screen area i.e. selection box), thus I use a combination of them.
  4. you can search actors by interface or by component or by class, I think any solution works.
  5. storing an array of selected units there should work.
  6. your camera system seems to be bad :stuck_out_tongue:

Hey guys,

thanks a lot for the quick help. I figured that I am probably better of using blueprints for now because thats a good way to learn the engines capabilities and clearly show stuff like: “you have to have a controller for AIMovement”.

Unfortunately I have encountered another problem. I want my Tanks to have a turning radius. Is there any function in the AIController which could cooperate such feature?

I really appreciate your help thus far and I am probably going to read the source code if nobody can lead me to the right answer.

Thanks

this article might help, but it is for a tile based pathfinder: http://www.gamasutra.com/view/feature/131505/toward_more_realistic_pathfinding.php?print=1 at “Adding Realistic Turns” section