Hot answers tagged

1

Select an object you want to center your view on and press the F key to snap your scene view camera to that object, zoomed to fit it in view. "Frame Selected" is the name of this shortcut.


1

What I’m describing was caused by the Rigidbody2D auto-calculate mass. Just uncheck that box and it should work fine!


1

The simplest implementation is for your Tile class to have two members: visible and opaque. Optionally, but a very useful third member is solid. visible: Is the tile currently visible by line of sight to the player? opaque: Does this tile block visibility of the tiles behind it? solid: Does this tile block movement? If a tile is not visible it should not ...


1

The problem was caused by manual replacing of .png picture in project's folder. At first time I didn't found a valid way to import an image as sprite, so I created a default one in Unity, which creates a sprite and a picture 1x1 pixels. Then I replaced it with my own picture, but metadata didn't change, and the Unity still worked with sprite like it is still ...


1

You just have to make the other characters do exactly the same things the player-character does, but with a delay. So you have to create a script which records the actions of the player and then allows to retrieve the player's position X steps ago. The C# standard already has the ideal data-structure for that, the Queue. It allows you to create a first-in-...


1

I managed to solve collisions problem by splitting the collision handling into horizontal and vertical components, one at a time. The implemented idea is: Move player on horizontal axis. Check for collisions. Solve collision on horizontal axis. Move player on vertical axis. Check for collisions. Solve collisions on vertical axis. This system does not ...


1

I'm on my phone and can't provide a super detailed answer, but here goes. This answer will not cover the physics calculation that you use, only the logic. It looks like there is trash data in your loop. When evaluating a body with itself, you do not update the angle and the acceleration, it remeains to what was used with a previous body. Whatever is in ...


1

This is what I figured out and it works, but Martin's answer is probably a lot more efficient. I went ahead and used the array of y values that I made, and then below it made a bunch of code segments like this: for (int i = 0; i < yValues.length; i++) { if (sprite.getY() == yValues[i]) { g2d.drawImage(sprite.getImage(), sprite.getX(), ...


1

instead of trying to identify the drawing order for each sprite itself you should create a proper drawing order first of. List<Sprite> sprites; Comparator<Sprite> topLeftComparator; void draw(Graphics graphics){ sprites.sort(topLeftComparator); //create proper drawing order first for (Sprite sprite: sprites){ sprite.draw(...


1

Generally it's up to you. Think about it in a abstract way. Read some articles and extract the ideas. Give it some time and gather the experiences. Imagine that games have something like GameObjects(player, enemy, bonus, wall, trap, weapon, etc.) Each such a object have some properties and methods like position, rotation, moveTo, scaleUp, etc. Those ...


1

this is how I solved this issue for myself. I hope it helps , ) In the frag shader the important bits are. . . vec2 rotate(vec2 v, float a) { float s = sin(a); float c = cos(a); mat2 m = mat2(c, -s, s, c); return m * v; } void main() { .... .... //The delta position of light vec3 LightDir = vec3(LightPos.xy - (...


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