Don’t sweat it. This thread is what, 109 pages? If I ever find the time I really should make a FAQ
Well, if you are an idiot then so am I. Took me a long time to figure out that one myself. Many of these networking things only seem simple in retrospect, I feel.
Hey, after looking through the blueprints for a while I just can’t figure out the solution to the problem myself.
Currently the pathfinding algorithm counts moving across a tile diagonally as the same distance as moving across a tile from one end to the other (I assume they both use 1 unit of range). The result is that the movement range looks like a big square, when it should look more circular in the real world. Is there any way to set the movement cost of moving diagonally to be higher than that of moving straight over a square (obviously the diagonal should cost sqrt(2) range) so that the movement range looks more natrual?
@QueSeraDilla: Hi there. The easiest way to achieve this effect is to increase the movement cost of everything by a factor of 10. That way, straight movement can cost 10 while diagonal costs 14. To do this, go to the GenerateGameplayGrids function in BP_GridManager and change the values as follows:
This will result in the following pathfinding (after increasing the move, max move and search range variables of the unit ten times):
In other news I’m considering temporarily excluding the 2D game example in the next update. I’m no longer happy with a lot of the code in that example, so I want to rework quite a lot of it. That would take a few days, however, and I want to get the update done soon. So I think I’ll skip it for now and add it back, new and improved, in the update following this one. If someone has any strong objections to this, let me know. You will all still be able to access the 2D game example from earlier versions of the toolkit in the launcher.
Trying to create a builder class character, and i cant seem to get him to spawn new actors (buildings) onto the grid. I tried to set up a funtion in the Unit_player class saying destroy actor and then spawn building. The button is in the hud but it does not seem to wanna work is there something i have to do with the grid its self
I would love to get the multiplayer integrated asap. I’ve considered reaching out to you just to get a nightly build of yours even as I am ready to start implementing server side validation of movement and skills so I can make my game ready for release without cheaters.
In what way is it not working? Is the unit not being destroyed at all, or is something else wrong? Start by printing a sting when you click the button to see if it recieves input at all and take it one step at a time from there. If you cannot find the issue, please describe the issue in more detail and I will try to help.
I’ve had a very productive weekend, so hopefully everyone should have a copy of the update fairly soon. Have patience and I’ll get it to you as soon as I’m able
Additional question, and I can’t find it anywhere in the thread really. We’re spawning tiles on runtime, not construction, and they have tile costs, however I can’t seem to find the functions i need to call so that this would work when they’re spawned in runtime, after the grid is setup. Would I resetup the entire graph after I spawned all additional tiles or is there one specific function(s) I’d need to call to let this happen without messing up the way the grid works?
Generally spawning tiles blockages based on a few factors but these are done during runtime, not construction script/level editor.
There is a Spawn Tile function in BP_GridManager for this purpose. There are also a few functions for manipulating tile edges directly under the utility tag in BP_GridManager’s functions, but I would first check if the Spawn Tile function does what you need it to.
Ah thanks for that one, also noticed just now the tile cost has to be 1, not 0 or -1 if you don’t want it to affect anything. Doing that fixed it Thanks!
Glad it worked Yeah, a cost of 0 removes the edge (makes it impassable), while a cost of -1 for corner tiles also removes the edges of tiles crossing that corner. Not exactly intuitive. I’ll put edge array manipulation as the topic of a future tutorial.
Hey, does anyone know how to make the HUD change for different classes of units, tried creating a binding on the visibility function on the widget editor but nothing seems to be working any ideas I can try would be awesome
An small update on the progress on the next version of ATBTT: I’ve found a new and better version to implement networked multiplayer than what I originally did. This means I will be delayed a few more weeks as I implement this new solution. Apologies to everyone who have been waiting for networked multiplayer for so long already, but I believe it is best to give you the best solution for networking right away instead of first giving you all something that is not ideal, which you will later have to heavily adapt when a new update comes.
Basically, what I originally did was to implement multiplayer as you would in a real time game (which the documentation and tutorials on networking are targeted towards). I would for example instantly replicate the movement and actions of all units from server to clients. As long as the clients have a stable, low latency connection this is no problem, but if this is not the case you get all the issues one is used to for real time networked games, with visible lag, actions happening out of sync etc.
Since there is much less need to be certain that all actions happen at the exact same time for all clients in turn based games, many of these issues can be avoided. What I am now doing is first simulating all actions and movement on the server, and then storing an array of actions in the game state of each client. Then each client runs through the array one at a time and displays/animates each action to the client. Since all these actions happen client side, there will be no visual hiccups in animation etc. due to network issues.
So again, sorry for the delay, but I hope it will all be worth the wait. The clearer distinction between calculating and animating actions will also have many potential benefits for single player games as well, and the game state animation array might be a useful tool for making in-game cinematics and the like as well.
That seems like a much better approach. One of the advantages of turn based game like this is not needing to worry about real time networking, which was one of the reasons we chose this game type for our next mobile game.
Is there a similar solution for round vision? I haven’t gotten through the forum yet, so this may be addressed, but is there a way to have a “spotter” or shared vision included?
I’m using a different algorithm for vision than for pathfinding for performance reasons, so the same solution will not work there. If you look in the GetTilesInRange function you’ll find the three different algorithms I use for making square, diamond shaped and hexagonal grids. The same can be done for round grids, but there is an easier, albeit slightly less performant, way to do this as well. Start with GetTilesInRange for square grids, then loop through the output array and remove any array elements for which index when inputted into the Vector Field Array is longer than a certain distance from the origin point. If you use Range * TikeSizeX as the cutoff you should get a round visibility pattern.
So I’m sorry this is the second time iv posted this but no one has given me an answer and i am a massive noob in unreal with only a small amount of experience but I’m really struggling to get custom huds for each class of unit after a good week of trying to do it myself I can’t seem to figure it out. Iv done some screenshot which I’m hoping might help people answer my question. Thank you in advance
Hi Paddysonn! I’ll do my best to help you with this, but it would be helpful to me if you could tell me a bit more about what your end goal is here. Are you trying to display the stats or name of the current unit on the screen, or is this something more complex? Are the widget blueprints for the different units fundamentally different, or could they be driven by the same widget blueprint with some parameters altered depending on the current unit? If you could describe what precicely you want to happen in game I can probably provide you with a good solution.
At the moment what I can do is point out a couple of errors in your code. Calls to parent events aren’t meant to be used like you do in your second screenshot. Any call to a parent event should be part of the execution chain of that event. If you call EventBeginPlay in your bottom screenshot, Parent:HudMelee will not be called, as EventHudMelee was never called. Disconnect Parent:HUDBuilder from Parent:BeginPlay and add a call after Parent:BeginPlay to EventHUDBuilder (not Parent: HUD Builder), and the execution chain makes more sense.
Also, in the Owning Player input node in your top screenshot you should add a reference to the player controller (use get player controller). That part probably won’t make a difference, but it is best practice.
Even if your solution works after making these changes, please describe what you are trying to do anyway, as I might be able to suggest some better ways to implement it.