# Tag Info

0

All the equations are in a frame with the y axis vertical pointing upwards and the x axis horizontal pointing in the direction of the movement. Your projectile undergoes the action of two forces: its own weight, always oriented towards the ground: $\vec{W} = -mg. \vec{y}$ the friction from the air (drag), opposing the direction of motion: $\vec{F} = -... 0 What do you think about rendering 2-3 states of the game world? Like, one which is "the stuff below the player", another which is "the stuff above the player", and more to suit your needs. Then simply render these in their respective order stuff below player -> player -> stuff above player Then instead of re-collecting the image ... 0 Even though the map is "small" at 100x100 with two layers, that's still 20,000 draw calls per frame. One optimization is to only draw the tiles that are visible such as limiting your camera's viewable area and zoom levels so you can't see more than a few hundred tiles at once. You'll have to implement the ability to query if a tile is visible to ... 0 Although your code already works and your problem is solved, the script can be cut down a little bit and become a bit more efficient. Instead of using an if statement wrapped in another if statement, you can simply combine the two together, as seen below: void OnTriggerStay2D(Collider2D other) { if (other.CompareTag("Player") && (Input.... 0 You have to compute the angle of the vector from the player to the mouse. get the mouse position by pygame.mouse.get_pos() and the rectangle (pygame.Rect) around the player (self.rect ): mx, my = pygame.mouse.get_pos() player_rect = self.rect Calculate the vector from the player to the mouse and compute the angle of vector by math.atan2. The y-axis needs ... 1 While D.Kallan focuses with his answer on how to make it closer to Brackeys', this answer focuses more on if you actually should do that. Since you are new to GameDev, I would guess for now most of your projects are for yourself and the learning experience. Instead of following the tutorial to the letter, you should make the game look great on your own ... 0 Quick solution but for other wait operations you might want to use a Coroutine. Invoke is not a real timer or counter but the second parameter allows you to specify the time amount when the call should be executed. In this case the function ResetJump will run 3 seconds later and reset your jump. void Update() { horizontalMove = Input.GetAxisRaw("... 1 When you want a method that can pause its execution and resume later in Unity, that's called a Coroutine, and it needs to be set up in a specific way. The return type has to be IEnumerator, not void. That's why the compiler complains when you try to put a yield return statement inside a void Update - "void" is not a type that can be used as an ... 1 I have noticed that when your camera is on Free Aspect, the size changes with the size of your game window. If you compare the differences between your UI and Brackeys' UI, you see that your game window is wider than his, and a little smaller vertically. Try resizing the game window to match his and your camera should then match about the same ratio as ... 0 It seems that there is no way as of right now to achieve that easily in Unity. So, in my case I was able to get going with the following: for the head I just use the -1 x scale for the collider object. That makes the collider match my mirrored head sprite. for the legs I just scale down the collider. That allows me to get a very nice precision. The ... 0 You can do it such as suggested in the comment section (using tilemap collision) or you can do it programmatically: if (playerX >= borderX && playerX <= borderX + borderWidth && playerY >= borderY && playerY <= borderY + borderHeight) you touch a border else player move 0 As far as I can understand, you are trying to stop the player from moving out of the border. I would recommend doing this by using a Tilemap and adding a Tilemap Collider to the Grid inside the Tilemap GameObject. Then, simply just create a tile palette and add the chosen image for the border. Then, you can "draw" with the tile painter in the ... 0 I really did not want to resort to the one collider per character solution. Even if it is a widespread approach, I feel satisfaction by making the character colliders as accurate as possible. So, I just added an edge collider under the character. A lot of my issues got gone after that. Including the issue described in the question. 0 First, let's make a simple data container to put on our fruit items. For now, this will contain just the image we want to display when we collect it. public class Collectable : MonoBehaviour { public Sprite sprite; public void Collect() { // Here you can spawn a collection effect or play a sound, etc. Destroy(gameObject); } } ... 0 The @DMGregory's comment is what I was looking for. I just take the character colliders and run for each one of them the call: foreach(var characterPartCollider in characterPartsColliders) { Physics2D.IgnoreCollision(groundCollider, characterPartCollider); } This makes the character fall down through a platform. Then when I detect a collision with ... 0 When your code doesn't work, the first thing you should try is usually adding some logging: public void LoadDataFromFile() { Debug.Log("Loading data from file..."); BinaryFormatter bf = new BinaryFormatter(); gameSave = new GameSave(); string path = Application.persistentDataPath + "/SaveData.dat"; ... 0 To prevent things from bouncing, what you want are "inelastic" collisions. In Unity all collisions below a configurable Velocity Threshold are inelastic. You can change that velocity threshold inside your Physics2D settings. (menu: Edit > Project Settings > Physics 2D). See also https://answers.unity.com/questions/1393846/rigidbody-sticks-to-... 2 The problem is that Unity allows you to put your Counter script on as many gameObjects as you want, and each one would have an own ScoreAmount. So Counter.ScoreAmount is ambiguous. Unity doesn't know which one you mean. So how could you fix that? Solution A: Make ScoreAmount static. When you declare a variable as static, then all instances of that script ... 1 So It seems I has to use this line return sample(tc, r)* smoothstep(1.0, 0.0, r); which solves the problem...Thank you! 1 Wrapping a tiled map can be achieved by rendering the TiledMap multiple times if the camera position is closer to the borders of the map than the size of the camera viewport. So for example on a map that is 16 world units wide and viewed by a camera with a viewport width of 8 and the camera is at X=2 then the map needs to first be renderer as normal using ... -4 Technically speaking, it’s all a matter of personal preference. Nearly all game engines have the ability to create the games you listed above. But, here’s a list of some of the engines best suited for what you want: Godot is an open source game engine that anyone can modify. It can compile games for nearly all devices. It is coded in GDScript, a Python like ... 0 You've nested your OnTriggerEnter2D method inside your Update method: void Update() { void OnTriggerEnter2D(Collider2D other)//I try to check for the checkpoint but failed { if (other.tag == "End") { LoadNextLevel(); } } } That means the method named OnTriggerEnter2D exists only when Unity ... 0 So I ended up getting it working, I had so many different issues trying to use so many different ways to find out the correct implementation, I had an extra offset in my map.SetTile() call which was putting me off! 0 Make a shader transition in any shader language (this website is a great one) and before loading the next scene, activate the transition. If the player enters the level (scene) then forward and backward when he exit. You can use a raycast with a collider at the end of the level to know if you are at the end of the level or not. 2 Here is my solution based on the answer given by DMGregory. This is Delphi Pascal. The LinearInterpolate function is just a lerp. Care has to be taken to avoid divide by zero. CamT.Scale := Exp(LinearInterpolate(Ln(Cam1.Scale), Ln(Cam2.Scale), k)); if abs(Cam2.Scale - Cam1.Scale) > 0.001 then begin r := Cam2.Scale / Cam1.Scale w := (Power(r, k)... 3 For a smooth loop like this, we want to scale the camera viewport from 1 x at the start to$r$x at the end of the first loop (where$r$is the ratio between the inner image size and the outer image), then$r^2$x at the end of the second loop,$r^3\\$ at the end of the third loop, etc. A function whose value compounds by some ratio each time we move a ...

2

I would recommend you to structure your project a bit differently. Instead of having the Respawn script on the player (I assume it's on the player) detect and handle all the interactions with different objects in the world, you should make those objects themselves responsible for detecting the player and triggering a response from it. So first of all, don't ...

0

You clearly know how to move the player to a spawn point when hitting a trap. You can use the same logic to move the spawn point to a checkpoint when hitting the checkpoint.

1

The Collision action matrix section of this page is always a great reference to look at. It shows what collision detection/trigger messages are sent when two objects collide. I would ensure that the player has a RigidBody2D (shouldn't matter if it's kinematic or not) and a Collider2D (with Trigger selected), and that the trap has a Collider2D (with trigger ...

0

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy. // Initiates when something ...

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.

0

Following the "are you open to solutions that do swap the tile shader to write to the depth buffer?" suggestion by DMGregory on a comment in my question I implemented another possible solution which greatly simplifies the maintenance of the project. Disclaimer This solution is implemented using shaders. Saying that I'm new to shaders is an ...

Top 50 recent answers are included