5

Most importantly: plan for remappable controls from the start. Different games use different conventions, and different players have different preferences. This is also important for accessibility - not everyone plays with the same hardware - electrically or biologically speaking - and the ability to remap controls can turn an impossible game into a ...


3

You have at least one obvious error at hand. foreach (RectangleShape obstacles in JumpAtObjectList) { MainPlayer.Jump(deltaTime, obstacles); break; } break tells the foreach loop to exit and since there is no condition, it will always exactly run one time for the first obstacles in JumpAtObjectList. What you probably wanted is to check if the ...


2

Since you have a tiled world and an exactly tile-sized character, a first step to sort out this problem can be to recognize when the character aligns with a tile. In the falling-into-a-hole case, this occurs when The Y coordinate is integer (assuming your tiles are side length 1), which should be true whenever sliding on a tile-aligned obstacle is happening....


2

Placing Nodes from code To change the position you need to… For a Node2D set the position or transform2D. For a Control set the rect_position (call set_position). For a Node(3D) set the transform. If you have a Node (scene loaded and instantiated) you want to add to the scene, you can do that before you call add_child on the pregnant future parent Node. ...


2

There are a couple setups that have become ubiquitous. Here are some common uses (non-exhaustive list): Left stick for Player movement Top-down shooters: Movement direction Clicking: Ducks Right Stick for Camera movement Top-down shooters: Shooting direction Clicking: Cycles zoom levels Centers the camera on the player Dpad: Player movement Side-...


1

Simpler approach is to set "Stretch Mode" (in project settings under Display -> Window -> Stretch) to "Viewport". With "Stretch Mode" set to "Viewport", the rendered resolution will match the design resolution (in project settings, under Display -> Window -> Size). This may result in enlarged "pixels&...


1

Since you do not need to reset the scene, all you need to do is Save the transform of the last checkpoint when you reach it. Destroy the current player. Instantiate the current player around the saved transform. Move the camera back to the player if it not done already.


1

Start with a simple refactor: the camera does not follow the player. The camera follows a target. Make the target the player. The game should behave exactly as it does right now. You will want to use interpolation, which you already do. Instead of doing player.Position - camera.Position you do target.Position - camera.Position. And target happens to be equal ...


1

After countless hours of finding the problem through trial and error and asking around on Discord servers and, of course, here, my friend and I found a very versatile solution for a particularly irritating problem. Credit is due to Kevin Reid who took his precious time to answer this post. He made a well written answer that explained a crucial concept within ...


1

If you use a tile-based level layout where a grid cell either contains a platform or not, then you implicitly solve the problem of preventing overlap. Indeed, it can happen in two ways: Additive approach: Start with all cells empty, then set "cell[x][y] = platform_tile" for each platform you add. Setting a given cell to platform twice won't matter as its ...


1

I struggled with this for a long time. For me, the solution was centered around having a correct snap vector. Using get_floor_normal() as snap when not jumping resolved my problem. For example: snap = get_floor_normal() if is_on_floor(): if Input.is_action_just_pressed("jump"): snap = Vector3.ZERO move_and_slide_with_snap(velocity, snap, ...


1

I handled that by using pooling (i.e. just enable/disable) for the interactive enities that are far/close to the camera view. The tricky part is do you want the logic to resume or restart upon reenabling them. In entity code you should be careful what values you set to be cached (or reset) when you disable entities (you can use OnEnable/OnDisable methods to ...


1

As DMGregory observed, it seems like your root issue is that you are setting dead to false each time you spawn a platform: public void Start() { dead = false; } You asked doesn't that mean it's set to false only once at the very start? As noted in the Unity documentation, "Start is called on the frame when a script is enabled just before any of ...


1

Well, basic setup of desired configuration can be achieved quite easily in Unity. SceneManager class has nice methods: LoadSceneAsync and UnloadSceneAsync. They are loading/unloading scenes in the background and provide convenient callbacks when scene loading is complete; you can initialize more than one scene like this: SceneManager.LoadSceneAsync("...


1

So technically, it already follows the player to the right, and you want it to move to the right and left side, while it stops if it gets too close? In the given context, I think this is all you need: if (obj_testPlayer.x > x + 34) { // want it to stop 34 pixels away from the players left xspd += 3 } else if (obj_testPlayer.x < x - 34) { xspd -=...


1

I find my solution activating an option in the Platform Effector 2D called "Use one way grouping". I have to say that I have no idea what it does, even after reading its documentation, but it seems to have done the trick. If anyone wants to expand on this, and add a more comprehensive answer, I would be happy to know about it.


Only top voted, non community-wiki answers of a minimum length are eligible