New answers tagged

1

I assume you already have implemented some function to check if the final spot is occupied by another piece. Use the same method on all the squares that a piece needs to follow (excluding the Knight) to see if that piece can actually travel that distance. Take the rook for example. It's not enough that the target to move to is empty, you also need to make ...


1

When the canvas is set to screen space overlay, the z isn't going to do anything as 'Screen space overlay' uses an orthographic camera which renders everything between z -1000 and z 1000 the same. It is not going to look like it is closer to the camera. That is just how an orthographic projection works.. I think you'd either want to set it to Screen space ...


6

Borrowing the diagram from disc_code22's answer, let's overlay it with some numbers. For each square, we're going to count how many squares it is left or right from the knight, and square it; then do the same for up/down; then add the two numbers together: You might recognize this as Pythagorean theorem, just without the square root (we don't need it if we ...


3

I imagine you have to do 8 expressions. All expressions using the x and y axes: if (mouse_x div 64) * 64 == x+64 && (mouse_y div 64) * 64 == y-128 || (mouse_x div 64) * 64 == x+128 && (mouse_y div 64) * 64 == y-64 || (mouse_x div 64) * 64 == x+128 && (mouse_y div 64) * 64 == y+64 || (mouse_x div 64) * 64 == x+64 && (mouse_y ...


3

There are quite a few approaches you could take to validating this kind of movement, so you should choose whatever is cohesive with the style of your movement validation so far, but I'll suggest a simple approach and perhaps you and other answerers can build on it. If your knight is at a position, lets say (x,y) on the chess board/grid, lets also imagine a ...


1

I think you'll want to pass a normalized vector into the movement function. Something that will combine the x and z movements into a single variable. Likely you'll need to use the Pythagorean theorem as well. This video may have what you are looking for: https://youtu.be/m7VY1T6f8Ak


0

The reason the pieces are not moving is that it never does the first section of code, and when it runs the second section, the only place it lets it move is the spot it is already in. It never runs the first section because when you click on the pawn the first time it changes the value of the variable before it even moves. In the second section, the mouse_y ...


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-...


Top 50 recent answers are included