c# – Move sprite in relation to parent?

I’m writing a simple game in C# and i’m having some difficulty to calculate the local position of a sprite.

What i’m aiming to achieve:

  • Calculate the spritelocal position” relative to the parent.

  • When the parent sprite position is changed, the children sprite should be aways following the parent while keeping its relative position.

Example:

Lets assume i have a parent sprite at world position (4, 4) and a children sprite at local position (2, 2), if the parent sprite world position moves to (5, 5), his children local position should be at (3, 3).

Below is a example code of what i’m trying to make.
Lets assume the parent of this sprite moved and UpdateChildren was called:

public class Sprite
{
    public Sprite parent;
    public Point world_position;
    public Point local_position;
    
    public void UpdateChildren(Point new_position)
    {
        // What should these numbers contain?
        this.world_position = ???
        this.local_position = ???
    }
}

Could someone provide a direct answer with the math to solve this problem?

Thanks in advance!

Unity 2d Sprite Swap Help

i know that that’s is a very old unity issue. I’m doing a 2d pixel art rpg and i want to sprite swap whenever the player gets an armor (helmet,vest,boots…). I created an empty gameobject and childed all armor gameobject.
After a long research i found the Unity Sprite Library Asset that can swap the sprites of a category. I have a helmet idle sprites and registering this to the sprite library i can succesfully swap the head helmet. The problem is that when i animate this, i can’t swap the sprites because the animations keyframes animates only one sprite.

Is there a way to help with my code?

How do I convert 2d character rigging animation to frame by frame sprite animation?

In this video https://youtu.be/vap04-Py9QM after about the 8th minute, he says he converted them from character rigged animation to the frame by frame animation, so I searched but couldn’t find any answers on google. How do I convert rigged 2d animations to frame-by-frame animations?

unity – How many Sprite Atlases should be used?

I am using Sprite Atlases in my game to fix a bug with gaps between tiles as a result of oversampling, and I started wondering how the atlases should be used.

What I’m asking here is whether I should use one atlas for all of the sprites, use multiple atlases as categories of some sort, or only use them with images with multiple sprites (to fix the bug).

java – Delayed rendering of object sprite

I’m trying to replicate an odd feature of an 2.5D online Fighting Game named Grand Chase – that I believe it’s is made to hide the latency between players. However, I do not know what exactly is this technique/feature, or if masking the lag is it’s real objective.

What matters is: It adds an visual input-lag for the player that does not exist, but it creates interesting out-of-sync situations that enable different player techniques that is unique on this game.

How it works:

This delayed rendering is applied to all actions except for when the character is being hit – the flinch/pain animation starts at the very same frame the game detects the collision.

This delayed feature is only applied to the player’s character. Other players on the match, both object/hurtboxes/hitboxes are in sync with the rendered character model and animations.

So, it only works for the player, not the opponents/allies.

When an input is made, the character object reacts instantly to whatever the desired action of said input, however the 3d mesh of the caracter are delayed for exactly 8 frames.

Example – a simple jab attack that has 3 frames of startup would play like this:

Press the key for the jab on frame 0 – the game already sends the attack player over the network for connected clients.

On frame 3, the character hitbox is now alive and collides with other object. Enemy character is already on the first frame of flinch/pain animation, However, the player charater is still on idle animation. Damage dealt is displayed, and HP is reduced from the target.
On frame 4, the particle effects of hit collision starts to be rendered where the hitboxes collided. Character is still on idle animation.
On Frame 8, character is no longer on idle animation, and is on the first frame of jab animation.
On frame 11, character is then stopped due to hitlag/hitstagger effect – this is when the player visually confirms that his hit has been confirmed.

Another example – Movement and taking damage

Frame 0 – Game confirms the dash input, so the object and hurtbox is already moving forward. The character model is still standing in place, on idle animation.
8 Frames later, then, the character switches from idle animation to the dashing animation and starts to move on screen.

When the character is moving fast and is hit by an attack/projectile going towards the character, the collision visual effect is displayed ahead of the character (it spawns where the hitboxes collided), the character animation instantly switches to the flinch/pain animation, where the character still goes forward for 8 frames, then stand still.

So, in reality, the player character object is updated in real time, only the character model is updated 8 frames later.

Anyone knows if there is any documentation on this?

I’m trying to replicate this for my own game on an self made Java 2D engine. On my engine, the object updates it’s state class responsible for movement/hitboxes/animation handling then, right after all states are updated, it calls the render function.

Ive tried buffering character X and Y coordinates for 8 frames, it kinda worked but i’ve failed when trying to buffer the animation frames, since it is updated on the state class, not on render function. Any tips are welcome!

unity – how to check if sprite is fully masked

enter image description here

i want my player use as a mask and when he go up of the sprite, the section of that sprite will be masked. when the full image is mask i want to give a pop up like “completed”.my main problem is i dont know how to know if the sprite is fully masked..one more problem is some parts of that sprite is alpha/transparent..i want to ignore alpha as completed

opengl – rotate sprite without stretching

I am attempting to rotate the sprites in my game, but they get stretched whenever it happens. I know that it is due to the screen not being square, but I can not figure out the correct way to compensate for that.

enter image description here
enter image description here

The left was taken from a non square screen, and the right is from a square screen. I need to scale it in a way that it will be normal again.
The code that I am using to move and rotate the sprites is below:

glm::mat4 temp = glm::mat4(1.0f);
float angle = glm::radians(45.0f);
temp = glm::scale(temp, glm::vec3(xScale,yScale, zScale));
temp = glm::rotate(temp, angle, glm::vec3(0f, 0f, 0f));
temp = glm::translate(temp, glm::vec3(coor(0), coor(1), 0.0f));
trans = temp;

coor is just the new coordinate to move the sprite to. What is an equation that can get me the X,Y,and Z Scale? I have access to the screen aspect ratio, and I know it has something to do with it. I tried multiplying it by the screen ratio, but that didn’t work. I multiplied them by the sin and cos of the angle, but that didn’t work either. What is an equation that works?

Can an ally or familiar with opposable thumbs (Imp, Sprite) doff and/or don the player’s shield?

It takes an action to don and to doff a shield (See Pg 146 of the PHB).

Does that action need to the PC’s action? Or, e.g. could another member of the party, or a familiar, spend their action remove a player’s shield?

unity – Sprite transparency fails when rendered through shader

I am currently trying to implement a shader to a sprite of mine, but the transparency is completely removed when the texture goes through a Sample Texture 2D node.

The sprite under the Sample Texture 2D node.

The sprite Import settings

enter image description here

The sprite on a image viewer.

enter image description here

unity – Sprite transparency is gone when going through shader

I am currently trying to implement a shader to a sprite of mine, but the transparency is completely removed when the texture goes through a Sample Texture 2D node.

The sprite under the Sample Texture 2D node.

The sprite Import settings

enter image description here

The sprite on a image viewer.

enter image description here