New answers tagged

1

I would recommend you to place the 2d sprite not in the game world but instead place it on a UI canvas with "Screen Space - Overlay" mode. You can convert the game-world position of a GameObject to screen-coordinates using Camera.WorldToScreenPoint. Then you need to convert the screen coordinates to canvas coordinates and place your sprite there. Code ...


0

I had this same issue, I was using sprites with 8 different directions of movement. Here's how I detected which direction they were moving in: The way the sprite is facing depends on the direction they were last moving in. You can find the direction of sprite movement by performing some calculations on their original coordinates, and the coordinates of ...


0

A very high-level thought would be to separate your sprite-sheet into different sheets for each direction so that on different key-presses you can specify which sheet to cycle through, and then you don't need to worry about confusing offsets


1

Ok, after 4 hours of searching finally I found the mistake. Problem was with the sprite origin. Here's the line that was necessary (staticBody is the body around other bodies will rotate) tmpSprite.setOrigin(staticBody.getPosition().x / 32 + tmpSprite.getWidth() / 2, staticBody.getPosition().y / 32 + tmpSprite.getHeight() / 2); And here's ...


0

I fixed it: import SpriteKit func + (left: CGPoint, right: CGPoint) -> CGPoint { return CGPoint(x: left.x + right.x, y: left.y + right.y) } func - (left: CGPoint, right: CGPoint) -> CGPoint { return CGPoint(x: left.x - right.x, y: left.y - right.y) } func * (point: CGPoint, scalar: CGPoint) -> CGPoint { return CGPoint(x: point.x * ...


3

first time here, have some time to kill so this is what I did. I'm assuming this is in a gui/2d game. This is what i did to get it to work. create a canvas and add 4 UI images. These act as the 4 points(vector3's) create a script and setup a way to draw lines so that you know that you are getting the right positions now you can move the images to make ...


0

Your code is fine as is, maybe some lines can be written better and optimizations are possible. But it does work. The reason your character animation glitches is because of the related collision mask. When your character runs, his legs move and - right like in real life - there's a brief moment when both of them aren't touching the ground. Because of the ...



Top 50 recent answers are included