unit – Snake tail in Snake game is not working properly

I make a simple snake game in Unity 2D. And the snake tail doesn't follow just behind the snake head as it should.

This is what is happening: https://imgur.com/a/zG6hbd7

Here is my code:

using System.Collections;

using System.Collections.Generic;
using UnityEngine;
using System.Linq;

Public class SnakeMovement class: MonoBehavior

private Vector3 fp;   //First touch position
private Vector3 lp;   //Last touch position

private float dragDistance;  //minimum distance for a swipe to be registered
private float speed = 13f;

private Rigidbody2D rb;
private Vector2 moveVelocity;

public GameObject tail;

public List tailPositions;

void Start() {
    dragDistance = Screen.height * 5 / 100; //dragDistance is 5% height of the screen
    rb = GetComponent();

void Update() {

    if (Input.touchCount == 1) // user is touching the screen with a single touch
        Touch touch = Input.GetTouch(0); // get the touch
        if (touch.phase == TouchPhase.Began) //check for the first touch
            fp = touch.position;
            lp = touch.position;
        else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved
            lp = touch.position;
        else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen
            lp = touch.position;  //last touch position. Ommitted if you use list

            //Check if drag distance is greater than ?% of the screen height
            if (Mathf.Abs(lp.x - fp.x) > dragDistance || Mathf.Abs(lp.y - fp.y) > dragDistance)
            {//It's a drag
             //check if the drag is vertical or horizontal

                if (Mathf.Abs(lp.x - fp.x) > Mathf.Abs(lp.y - fp.y)) {   //If the horizontal movement is greater than the vertical movement...
                    if ((lp.x > fp.x)) {   //Right swipe
                        if(moveVelocity != Vector2.left) {
                            moveVelocity = Vector2.right;
                    else {   //Left swipe
                        if(moveVelocity != Vector2.right) {
                            moveVelocity = Vector2.left;
                else {   //the vertical movement is greater than the horizontal movement
                    if (lp.y > fp.y) {   //Up swipe
                        if(moveVelocity != Vector2.down) {
                            moveVelocity = Vector2.up;
                    else {   //Down swipe
                        if(moveVelocity != Vector2.up) {
                            moveVelocity = Vector2.down;



void FixedUpdate() {
    Vector3 lastPos = transform.position;

    rb.MovePosition(rb.position + moveVelocity * speed * Time.deltaTime);

    if (tailPositions.Count >= 1) {
        tailPositions.Last().position = lastPos;
        tailPositions.Insert(0, tailPositions.Last ());
        tailPositions.RemoveAt(tailPositions.Count - 1);

void OnTriggerEnter2D(Collider2D trigger) {
    Vector2 spawnPos = new Vector2(5, 5);

    if (trigger.tag == "Food") {
        GameObject newTail = Instantiate(tail, spawnPos, Quaternion.identity) as GameObject;
        newTail.transform.parent = GameObject.Find("Tail Holder").transform;


Thank you very much for taking the time to help me.

Rendering – Unreal Engine – Occlusion removal doesn't seem to be working properly

I play with environments bought on the market, one of which has a fairly intensive map with many houses and many detailed interiors for the houses. I was under the impression that Unreal allows dynamic occlusion felling by default, but it seems that occluded meshes are still being rendered. See the comparison of "stat initviews" below:

enter description of image here

enter description of image here

There is not much difference in the number of occluded objects (hopefully eliminated) between these two camera views, and my performance is very similar in both. Am I misunderstanding how occlusion is working in the EU, or is it not working right for me? How can I be sure that occluded objects are not returned?

windows 10 – ASUS Aura does not work properly

I bought an ASUS ROG laptop a few months ago, when I arrived I formatted it with Win10 and then installed all the ASUS packages needed so that all the LEDs and everything work fine – at least that's what I thought. Sometimes they worked and other times they suddenly stopped responding or went out, especially if I'm joking with Aura to change the effects.

Yesterday I picked it up to keep working and the LEDs didn't light up no matter what. It was dark in the room and I just wanted to turn on all backlight on my keyboard. I even restarted the machine many time.

Startup sequence: the LEDs flash / hover over the keyboard in red, the screen showing the ROG BIOS logo, then continues to apply the last effect selected in the Aura application, then starts, but as soon as Windows goes into action (black screen before the connection appears), all the LEDs go out.

I uninstalled and reinstalled all ASUS packages, even those that do not relate to it, deleted all Registry entries containing "ASUS". Fact Dism /Online /Cleanup-Image /RestoreHealth, restarted services, tried reinstalling again, switch files to older versions, erase AppData from all ASUS packages, even download AuraCleaner. Literally everything you could think of. Nothing worked.

After almost going crazy over certain features that weren't working, I looked at the services one last time. I deactivated each ASUS service, then restarted. It passed through the black screen and the LEDs stayed on, much to my surprise.

After thinking about activation / deactivation services, I more or less isolated the culprits.

TLDR, partial solution:

Disabling only "ASLDRService" and "ASUS Com Service" operates Aura normally, but the shortcut key to the ARMORY Crate app is now dead.

What can / should I do to resolve this problem? Reactivating these services kills the LEDs on the next start.

Any help is greatly appreciated.

I have detailed my conclusions here mainly to help people who are having the same problem. Although it is not resolved, it is at least something.

Nvidia GEFORCE GTX 1050 TI does not work properly

I just want to know if someone has faced the problem I am facing now and a cure for this itch.
i have a NVIDIA GEFORCE GTX 1050 TI with 6 GB RAM, 2nd generation Intel i3 processor and Foxin 800 SMPS.

When I add the card into the slot, it works well. But sometimes, by shaking the mouse and keyboard lightly, hibernation disappears ( I mean it hangs ).

Recently I had to remove the card and when I added the monitor to the card I don't get a display at all via the HDMI port, I tried to ;use VGA, it works well.

Is my card faulty or something more is happening, which causes the mouse and keyboard to hang?

c ++ – Rendering text using the FreeType library does not work properly

Currently, I'm implementing text rendering in my game engine using the FreeType library by following the tutorial found here: https://learnopengl.com/In-Practice/2D-Game/Render-text. My current implementation is not working properly, you can see the result of my implementation in the following images (note that I make the text "Test test", and you can see 8 distinct cubic shapes one for each letter with a space in between ) words, the last 4 cubic forms being smaller and of different form compared to the capitalized version of the word, it therefore seems that it is at least close to rendering the string "Test test"):

enter description of image here

enter description of image here

First, there are obvious problems, to start with, you can see that the "text" is drawn from a projection perspective rather than orthographic, this is on purpose however because my system is already drawing with a perspective of projection and if the text was stuck flat on my screen in a 2D I do not see how the perspective in which it is drawn would change anything.

This leads to the following problem, the "text" is not pasted on my screen in a 2D way (like HUD elements in a game), it seems to float in 3D space, although if I look at the "text" exactly from the side, it will disappear, so it doesn't seem to have depth (z axis), only one position on the x and y axis. In addition, if I go beyond the right side and look from behind, the "text" disappears.

And finally the most obvious problem, the glyphs clearly are not rendered correctly because you cannot see the actual shape of the letters, but just the cubic space containing the letter.

My implementation is as follows:
((Warning: My engine is too big to explain every little thing that happens so this question shows a minimal code and only code relevant to this problem, described in a fairly high way)

In my engine, the scene is created using a scene graph of GameObjectis each with GameComponentthis is why i am creating a TextRendererObject and add a TextRenderer and add it to the scene in the following code:

Entity *textRendererObject = new Entity(...);
TextRenderer  *Text;
Text = new TextRenderer(50, 50);
Text->Load("font/arial.ttf", 240);

the TextRenderer builder a struct that the .h defined file (used in load function) and load are respectively as follows:

TextRenderer::TextRenderer(GLuint width, GLuint height) :
    TextShader("text")//creates text shader (text.glsl)
   GLuint VAO, VBO;


    glGenVertexArrays(1, &this->VAO);
    glGenBuffers(1, &this->VBO);
    glBindBuffer(GL_ARRAY_BUFFER, this->VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
/// Holds all state information relevant to a character as loaded using FreeType
struct Character {
    GLuint TextureID;   // ID handle of the glyph texture
    glm::ivec2 Size;    // Size of glyph
    glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
    GLuint Advance;     // Horizontal offset to advance to next glyph
std::map Characters;
void TextRenderer::Load(std::string font, GLuint fontSize)
    // First clear the previously loaded Characters
    // Then initialize and load the FreeType library
    FT_Library ft;
    if (FT_Init_FreeType(&ft)) // All functions return a value different than 0 whenever an error occurred
        printf("ERROR::FREETYPE: Could not init FreeType Library");//std::cout << "ERROR::FREETYPE: Could not init FreeType Library" << std::endl;
    // Load font as face
    FT_Face face;
    if (FT_New_Face(ft, font.c_str(), 0, &face))
        printf("ERROR::FREETYPE: Failed to load font");//std::cout << "ERROR::FREETYPE: Failed to load font" << std::endl;
    // Set size to load glyphs as
    FT_Set_Pixel_Sizes(face, 0, fontSize);
    // Disable byte-alignment restriction
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    // Then for the first 128 ASCII characters, pre-load/compile their characters and store them
    for (GLubyte c = 0; c < 128; c++)  
        // Load character glyph 
        if (FT_Load_Char(face, c, FT_LOAD_RENDER))
            printf("ERROR::FREETYTPE: Failed to load Glyph");//std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
        // Generate texture
        GLuint texture;
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        // Set texture options

        // Now store character for later use
        Character character = {
            glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
            glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
        Characters.insert(std::pair(c, character));
    glBindTexture(GL_TEXTURE_2D, 0);
    // Destroy FreeType once we're finished

The shader (text.glsl) created when the Textrenderer the object is created is as follows:

#include "common.glh"

varying vec2 texCoord0;
varying vec3 worldPos0;

#if defined(VS_BUILD)
attribute vec3 position;
attribute vec2 texCoord;

uniform mat4 T_model;
uniform mat4 T_MVP;

void main()
    gl_Position = T_MVP * vec4(position.xy, 0.0, 1.0);
    texCoord0 = texCoord;
    worldPos0 = (T_model * vec4(position.xy, 0.0, 1.0)).xyz;

#elif defined(FS_BUILD)

uniform sampler2D H_text;
uniform vec3 H_textColor;

DeclareFragOutput(0, vec4);
void main()
    vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(H_text, texCoord0).r);
    vec4 color = vec4(H_textColor, 1.0) * sampled;
    SetFragOutput(0, sampled * color);

Following this implementation of the textRenderObject game object, sound Text game component and text.glsl shader, at each image, the following rendering function is called:

void TextRenderer::RenderTextRenderer(...) {
    this->TextShader.Bind();//"text.glsl" created earlier
    RenderText("TEST test", 100, 100, 1);//responsible for drawing 

UpdateUniformsTextRenderer(...) is responsible for defining values uniformpeach text.glsl and looks like this:

void Shader::UpdateUniformsTextRenderer(Transform* transform, const RenderingEngine& renderingEngine, const Camera& camera)
    Matrix4f worldMatrix = transform->GetTransformation();
    Matrix4f projectedMatrix = camera.GetViewProjection() * worldMatrix;
    for (unsigned int i = 0; i < m_shaderData->GetUniformNames().size(); i++)
        std::string uniformName = m_shaderData->GetUniformNames()(i);
        std::string uniformType = m_shaderData->GetUniformTypes()(i);

         if (uniformName.substr(0, 2) == "T_")
            if (uniformName == "T_MVP")
                SetUniformMatrix4f(uniformName, projectedMatrix);
            else if (uniformName == "T_model")
                SetUniformMatrix4f(uniformName, worldMatrix);
                throw "Invalid Transform Uniform: " + uniformName;
        else if (uniformName.substr(0, 2) == "H_") {
            if (uniformName == "H_text") {//Texture used to draw text
                int samplerSlot = renderingEngine.GetSamplerSlot(uniformName);
                SetUniformi(uniformName, samplerSlot);
            else if (uniformName == "H_textColor")
                SetUniformVector3f(uniformName, Vector3f(1, 0, 0));//red

And finally the function RenderText who actually draws the text is:

void TextRenderer::RenderText(std::string text, GLfloat x, GLfloat y, GLfloat scale)

    // Iterate through all characters
    std::string::const_iterator c;
    for (c = text.begin(); c != text.end(); c++)
        Character ch = Characters(*c);

        GLfloat xpos = x + ch.Bearing.x * scale;
        GLfloat ypos = y + (this->Characters('H').Bearing.y - ch.Bearing.y) * scale;

        GLfloat w = ch.Size.x * scale;
        GLfloat h = ch.Size.y * scale;
        // Update VBO for each character
        GLfloat vertices(6)(4) = {
            { xpos,     ypos + h,   0.0, 1.0 },
            { xpos + w, ypos,       1.0, 0.0 },
            { xpos,     ypos,       0.0, 0.0 },

            { xpos,     ypos + h,   0.0, 1.0 },
            { xpos + w, ypos + h,   1.0, 1.0 },
            { xpos + w, ypos,       1.0, 0.0 }
        // Render glyph texture over quad
        glBindTexture(GL_TEXTURE_2D, ch.TextureID);
        // Update content of VBO memory
        glBindBuffer(GL_ARRAY_BUFFER, this->VBO);
        glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); // Be sure to use glBufferSubData and not glBufferData

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        // Render quad
        glDrawArrays(GL_TRIANGLES, 0, 6);
        // Now advance cursors for next glyph
        x += (ch.Advance >> 6) * scale; // Bitshift by 6 to get value in pixels (1/64th times 2^6 = 64)
    glBindTexture(GL_TEXTURE_2D, 0);

And this is my implementation, can anyone see where i was wrong? Any feedback is highly appreciated.

Why is my film clear? My processing is good and the camera is advancing and seems to be working properly. I am confused! Help me!

I'm shooting a film with a Nikon SLR. I have already shot thousands of films with other cameras. I made sure (twice) that the film was really advancing. I checked the mirror mechanism and the film feed reel and the shutter. They all work well. Cooking. My light meter seems to be accurate and working and my chemicals are good. I used them the same day with other movies. My film is clear! only a few tiny light streaks are visible on the film. I have never seen this before. Can anyone help?

magento2 – Resizing Magento 2 images does not work properly

The images of my products have a size of 600 x 600 px. in the view.xml file I configured:


But the images I get in the category page are 300 x 300 px, not 300 x 366 px.
Any help would be appreciated!

rom – Unable to properly decompress android 10 boot.img

Devices: sanders and rolex

Unpacking / repackaging boot.img was fine until android 9 on most roms.

But, impossible to decompress "boot.img" from android 10 roms,
tried boot.img of Android 10 based on Havoc, Lineage etc.

want to modify "init.rc"
but only by getting the "init" file and some empty folders like

enter description of image here

Using Android.Image.Kitchen.v3.6-Win32.
enter description of image here

differential equations – WhenEvent when using NDSolve does not work properly

sol = NDSolve({x''(t) == -x(t)*t + a(t)*x(t), x(0) == 1, x'(0) == 0, 
   WhenEvent(x(t) == 0, Tb(t) -> t), 
   WhenEvent(t > Tb(t) + 0.5, a(t) -> 1), 
   WhenEvent(t <= Tb(t) + 0.5, a(t) -> 0), Tb(0) == 0, a(0) == 0}, {x,
    Tb, a}, {t, 0, 10}, DiscreteVariables -> {Tb, a})

I am trying to solve a differential equation with some discrete components (Tb (t), a (t)). Tb (t) is supposed to be a stair function that records the moments at which x (t) = 0. Tb (t) works as expected:
enter description of image here

a (t) however, does not work as expected. a (t) had to go from 0 to 1 each time (t- (Tb (t) +0.5)) is equal to zero, but as we can see on the images below, a (t) does not makes the first shift correctly, then stagnates at 1 when it should be moving back and forth.

enter description of image here

How can I make this work properly.

port forwarding – SSH multiplexing hangs if it is not properly stopped

I am trying to configure remote access to my personal computer via SSH with multiplexing. Here is the configuration: from my laptop, I connect to a port on my modem; this port is forwarded to my router, which then forwards it to the local office and i authenticate myself with my key. Due to multiplexing, I can then open another connection to the home box without having to re-authenticate myself. It all works exactly as I expected.

However, a problem occurs when I restart the laptop. If I restart, I can no longer SSH in the startup box – trying to do so hangs a bit without asking me to authenticate, then expires.

I can fix the problem by restarting the welcome box (although this requires physical presence, which rather defeats the point). I can also avoid triggering the problem if I properly disconnect the SSH connection with ssh -O exit $IP -p $PORT.

Given the above, I have two questions: first, is this the expected behavior or have I encountered a bug? And, secondly, is there a way to avoid this problem? Thank you!

(This question is superficially similar to the configuration of the SSH multiplex timeout, but this The question concerns the restart / inaccessibility of the server while my question concerns the restart of the client without graciously signaling the end of the multiplexed connection.)