Good afternoon. I have a question. My friend and I are making a 2D game similar to Starbound. We wanted to create a looped world, but we’re facing a problem. We can either make the world in the form of a cylinder or use a teleport at the ends. However, I don’t know how to implement either option. In the cylinder, I don’t understand how to wrap the tile set into a cylinder, and in the second option, I don’t know how to implement enemy movement and physics. Can you please tell me how to do it correctly? I tried to search for information, but I couldn’t find it. I even tried to contact a neural network, but it gets confused and doesn’t always provide the same information, and sometimes it’s unclear what it means.
Usually for such things the world is divided into parts, which are loaded in front of the player and unloaded behind him (often used in levels with a train or tunnel).
I’m not sure how “right” this method is in this case, but I would start with it.
The simplest (in my opinion) is to use Level Instance Actors. If your level is divided into sublevels - all that remains is to load the required instance of the level in front of the player when he approaches the border of the previous one.
You can make triggers in the level parts and specify in them the soft reference to the sublevel that needs to be loaded next.
The only nuance is with dynamic objects (including NPCs), which may end up in the wrong area. For them, you need to create a separate sublevel that will always be loaded, or dynamically spawn such objects.
Got it, thanks for the idea. although I don’t quite understand it. how it should work. you can tell us in more detail. if I understood correctly, I should have conditionally several tile maps that will load around the players when they enter their zones. but with the NPCs, I didn’t understand at all. Why do they need another map layer? I have, in fact, a rounded terrarium map. that is, according to the idea of 1 tilemap. and I need to split it into a two-dimensional array of small tilemaps and connect them? and when the player approaches the edge, a copy is built outside for interaction, and the player is teleported to the edge? and then I need a three-dimensional array. 1 layer for structures and 1 layer for objects like NPCs?
Yes, you need to split the level into at least three parts, where the first and last ones create an unnoticeable joint (or, just always have three instances of one seamless level).
If dynamic objects are in a sublevel that is loaded/unloaded (Level Instance Actor) - then you may encounter a situation where your NPC followed you and then simply disappeared before your eyes because the sublevel to which he belongs was unloaded. This also applies to items that the player can take with him.
Your level is straight, you just constantly load a copy of it in front of the player (and unload the same one behind his back).
And here it is. such a question. tobizh, we walk around 1 location with teleports, but on its squares… links to the same tile map (it will also expose … destruction, so to speak.) or they are precisely loaded sequentially one after the other, as if they were rearranged. if the latter, then the question is, how will multiplayer interact with this? that is, if I run away for 3 scrolls of the map, I will not see my friend according to the idea. our coordinates will be different. That’s where I haven’t fully understood yet.And yes, thank you very much.
This makes the process of deceiving the player much more difficult…
The option with teleporting the player (without any endless level loading) starts to make more sense…
I meant it.
You can replicate the local coordinates of the player relative to his world (the level instance he has loaded), and the second client will use them to set the coordinates for its copy of the other player relative to self world (level instance).
P.S. Horrible things start to creep into my head, like capturing an image of a flat tile of the world and draw it onto a cylinder.
But I already see problems with collisions (which won’t happen in this case…)
You just need to make teleportation triggers that will move everything that hits them to the opposite trigger of the level. The function for setting location has flag for saving inpulse. So this shouldn’t be a problem…
UPD: And then I realized that after teleporting you won’t see the NPC who was following you until he teleports too.
The air begins to fill with the scent of portals…
It seems we will need SceneCapture2D to see everything that has not yet reached the trigger, but is in the player’s field of view.
Requiring to teleport or dupe parts of the level isn’t a performance friendly approach, and introduces other challenges.
Looking at the simplest implementation, you have a character walking around a cylinder. Gravity is not altered (we’re just walking left and right around a cylinder), so I don’t see why physics would need to be changed.
Movement would be simple to implement. You don’t have to alter the movement component or anything. Around the cylinder, you can wrap a spline component (a closing circle).
Your character receives input to walk in any direction just as in any default project. Added to that, your character location snaps to the closest point on the spline during Tick. That means, he can walk in any direction, but will never leave the spline. This effectively makes your character move around the cylinder at a fixed distance (right on the spline). Additionally you can decide to only snap some directions, so that you can still jump around.
This gives you a “Klonoa” type of movement.
Code example:
FVector NewPosition = GetActorLocation();
FVector SplinePosition = GetSplineComponent()->GetLocationAtSplineInputKey(GetSplineComponent()->FindInputKeyClosestToWorldLocation(NewPosition), ESplineCoordinateSpace::World);
if (MustSnapPositionXToSpline()) {
NewPosition.X = SplinePosition.X;
}
if (MustSnapPositionYToSpline()) {
NewPosition.Y = SplinePosition.Y;
}
if (MustSnapPositionZToSpline()) {
NewPosition.Z = SplinePosition.Z;
}
SetActorLocation(NewPosition);
Only challenge that remains is wrapping your tile map around a shape. What is it you are using, Paper2D? Look for some 2D plugin that can do it out of the box, if it can’t. Then you might not even have to implement a spline.
When looking for keywords, such plugin with a “wrap around” feature can use any trick, not necessarily a cylinder. “3D tileset” “wrap around 2D map” hmmm
what about the rake and the thrown objects (the conditional grenade). they fly all over the world. well, let’s say I can imagine making a turn and setting the flight based on it, but I have a vague idea of how to wrap the rake. or rather, I have no idea at all.
and yes. I haven’t fully figured out how to properly program in unreal yet, so I’m still using bluprint. Can you recommend some good materials for learning? and thanks for the idea of implementation.
Youtube channels:
mathew wadstein (lots of blueprint tutorials)
freya holmer (lots of math and shader tutorials)
Stuff about networking:
Cedric Neukirchen (look for his PDF on google or his website)
UI and input:
In general:
EPICs unreal documentation but it’s all over the place (if you don’t know where to look / what questions to ask).
And if you’re looking for features, tools, game mechanics that are fully implemented (game ready), you can take a look at some of my stuff on FAB or Github. From my GitHub you can learn how to implement plugins, C++, blueprints properly.
If you end up using something like a circle spline to snap objects to, then thrown objects would snap to the nearest spline point on X/Y/Z as well. Or, since projectiles rarely have a large lifetime (they despawn at X distance or time), and a map is usually big (so the curve of the world isn’t that noticable), you might just let projectiles travel a straight path (yes, they will move slightly away from the circle in time).
I also wonder how Terraria optimized (and it wraps?) their large tile based map. I think there is a video about how they did it on youtube.
People are waiting for them to dig into the sources of the terraria. it seems like it will be developed, but it is not known when
now I’m trying to figure out what what you wrote about the spline means. honestly, I didn’t understand how to implement this. I’m not very experienced with c++ yet, I haven’t figured it out in anril yet. can you explain a little more in detail
(post deleted by author)