## How to properly delete unwanted models

I am implementing bullets into my game, and each bullet has a lifetime. Whenever the bullet has existed for a set amount of time or collides with an object, the bullet should be deleted. I implemented the timer properly and whenever the bullet reaches the end of its life, it gets deleted. The problem occurs whenever I shoot another bullet. This instantly causes a crash with the code: `Exception thrown at 0x044765D7 (nvoglv32.dll) in gravityGame.exe: 0xC0000005: Access violation reading location 0x00000000.`

After some research, I’ve found that this usually means that I am trying to render something that is a `nullptr`. My thinking is that I am not deleting the previous bullet properly and this affects the new one. A single bullet object is created on startup, and every new bullet is copied using the following line of code:

`std::shared_ptr<Bullet> bullet = std::make_shared<Bullet>(*std::dynamic_pointer_cast<Bullet>(modelsLoaded.at(i)));`

The reason for the dynamic pointer cast is because it is in a vector of its base class that it inherits from. Whenever the bullet needs to get deleted, it is erased from the bullets vector using `bullets.erase(bullets.begin()+index);` and the object it is pointing to should go out of scope, there is nothing else pointing to it. I feel like somehow having that object getting deleted has an adverse effect on the other bullets in the vector, but I do not know how. A new object is created and all the data from the original bullet gets copied over. How could deleting a copy of an object mess with the other copied objects? The functions to create, and render the models are below.

Generate Model Function

``    //binds id     glGenBuffers(1, &VBO);     glGenVertexArrays(1, &VAO);     glGenBuffers(1, &EBO);     glGenTextures(1, &texture);     glBindVertexArray(VAO);     glBindBuffer(GL_ARRAY_BUFFER, VBO);     glBufferData(GL_ARRAY_BUFFER, verticesSizeTexture * 8 * sizeof(float), verticesTexture, GL_STATIC_DRAW);     // position attribute     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);     glEnableVertexAttribArray(0);     // color attribute     glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));     glEnableVertexAttribArray(1);     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);     glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesSizeTexture * 4, indicesTexture, GL_STATIC_DRAW);     //texture     glBindTexture(GL_TEXTURE_2D, texture);     glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));     glEnableVertexAttribArray(2);      glBindBuffer(GL_ARRAY_BUFFER, 0);     glBindVertexArray(0); ``

Rendering Function

``    unsigned int transformLoc = glGetUniformLocation(shader->ID, "location");         glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(trans));      glBindTexture(GL_TEXTURE_2D, texture);        glBindVertexArray(VAO);      glDrawElements(GL_TRIANGLES, indicesSizeTexture, GL_UNSIGNED_INT, 0);     glBindVertexArray(0);    ``

Destructor

``glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); glDeleteBuffers(1, &EBO); ``

Update After removing the contents of the destructor, the problem goes away. However, I would like to have some sort of destructor to allow for the proper freeing of memory.

## How to properly overflow 2D coordinates on an overflowing/circular map?

I made a simple Snake game designed for trying Snake bots. I thought the base map functions work, but now I found there is an error. What I need is to properly translate any coordinates outside the actual map to coordinates within it.

For example, if you’re at the right edge of a 10×10 map and you go to (zero-indexed) [10, 5], you’d expect to pop out at [0, 5]. That works in my implementation, but not the negative overflow. I tried a lot of formulas in the dev console and just can’t figure it out. Consider this code:

``    /**      * Normalizes overflow of a point so that it is within the map      * @param {number|Vector2} x      * @param {number} y      * @returns {Vector2}      */     normalizePoint(x, y) {         if (x instanceof Vector2) {             y = x.y;             x = x.x;         }          // auto overflow         if (x >= this.size) {             x = (x % this.size);         }         else if (x < 0) {             // ???         }         if (y >= this.size) {             y = (y % this.size);         }         else if (y < 0) {             // one of the formulae I tried, does not work for all values             y = this.size + (y-1) % this.size;         }         return new Vector2(x, y);     } ``

`Vector2` is a simple object with properties `x` and `y`. `this.size` represents the map size. For negative coordinates, I am not getting the correct results. I want overflowing X and Y coords to resolve to the same numbers. For example for a 5×5 map, all rows should be equal X coords after normalizing:

Real map coord X: 0 1 2 3 4
Negative alternatives: -5 -4 -3 -2 -1
Negative alternatives: -10 -9 -8 -7 -6

I would prefer it to be a O(1) formula, rather than some weird loop. With a loop, I solved it like this:

``if (x < 0) {             while (x < 0) {                 x += this.size;             }         }  $$```$$ ``

## Description

I’ve seen some Unity tutorials and I’m trying to apply good practices to modularize the code. However, I’m running into some issues while trying to use `rigidBody2d.MovePosition()`.

I have two classes: `Player` (which defines rules and performs calculations) and `PlayerController` (uses computed data from `Player` to interact with Unity itself).

`Player.cs`

``using UnityEngine;  public class Player {     public Vector2 MoveTowards(Vector2 currentPosition, Vector2 direction)     {         return currentPosition + direction * 2f;     } }  ``

`PlayerController.cs`

``using UnityEngine;  [RequireComponent(typeof(Rigidbody2D))] [RequireComponent(typeof(Animator))] public class PlayerController : MonoBehaviour {      public Player player;      Rigidbody2D rb2d;     Vector2 movementDirection = Vector2.zero;      void Awake()     {         player = new Player();         rb2d = GetComponent<Rigidbody2D>();     }      void Update()     {         movementDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));     }      void FixedUpdate()     {         rb2d.MovePosition(player.MoveTowards(rb2d.position, movementDirection) * Time.fixedDeltaTime);     } }  ``

What happens visually is the player’s sprite moves (just a tiny bit) towards the given direction and goes back to (x: 0, y: 0) as soon as I release the movement key.

Player on Inspector:

## What I tested

Inside `FixedUpdate`, it does not work when I use:

``rb2d.MovePosition(player.MoveTowards(rb2d.position, movementDirection) * Time.fixedDeltaTime); ``

Inside `FixedUpdate`, it does not work when I use:

``Vector2 controllerNewPosition = rb2d.position + movementDirection * 2f; rb2d.MovePosition(controllerNewPosition * Time.fixedDeltaTime); ``

Inside `FixedUpdate`, it works when I use:

``rb2d.MovePosition(rb2d.position + movementDirection * 2f * Time.fixedDeltaTime); ``

## Questions

Maybe that is being caused by the operator `+` and not creating a new Vector2, instead mutating `rb2d.position`? While I’m not new to programming, I have no experience with C#, so I don’t know the specifics of the syntax yet.

How could I use `player.MoveTowards` in this case?

# Edit

Feeling dumb. Right after publishing the question I realized the glaring mathematical priority issue. I’ve been debugging this for hours. I guess it happens to everyone.

## Need help improving my Flow Field and Unit Avoidance code so that the units can properly surround a unit instead of getting stuck

My setup is like this. Every update my movement system moves all of the units on the field. They use some Boid logic to avoid eachother, and a flow field that directs them towards each other. This is the result. https://imgur.com/a/CaUpfT7

My general setup is to calculate 2 flow fields, one for each player. From every field on the map (32×32 fields) I calculate the vector that points towards the closest enemy. Now this is a fine approach but I’d like to somehow take into consideration obstacles somehow (without another round of for loops)? Or should I handle that in my movement system avoidance? I was maybe thinking of doing A* once a unit is close enough to the enemy but all of these systems together seem rather hacky and overkill.

There are no obstacles currently, maybe a spell will generate it in the future. For now there are only units on the battleground without terrain or obstacles (besides units fighting eachother)

Here is some code. Firstly how I create the flowfields (kinda costly, will look into a way to optimize it further, don’t really need every single tile, can probably merge 2 or 3 together)

``func (g *Grid) Update() {     g.entityPositions[0] = g.entityPositions[0][:0]     g.entityPositions[1] = g.entityPositions[1][:0]     entities := g.world.GetEntityManager().GetEntities()     posComps := g.world.GetObjectPool().Components["PositionComponent"]      for _, ent := range entities {         g.entityPositions[ent.PlayerTag] = append(g.entityPositions[ent.PlayerTag], posComps[ent.Index].(components.PositionComponent).Position)     }      for x := 0; x <= g.MaxWidth/FlowTileSize; x++ {         for y := 0; y <= g.MaxHeight/FlowTileSize; y++ {              curPosVector := engine.Vector{X: float32(x * 32), Y: float32(y * 32)}             // find closest tile to this one for both players             minDist := float32(100000.0)             minIndx := -1             for indx, pos := range g.entityPositions[0] {                 d := engine.GetDistanceIncludingDiagonal(pos, curPosVector)                 if d < minDist {                     minIndx = indx                     minDist = d                 }             }              //  fmt.Printf("CurPos : %v, enemyPos : %v,  direction %v \n", curPosVector, g.entityPositions[0][minIndx], g.entityPositions[0][minIndx].Subtract(curPosVector).Normalize())             g.flowTiles[1][x][y].Direction = g.entityPositions[0][minIndx].Subtract(curPosVector).Normalize()              minDist1 := float32(100000.0)             minIndx1 := -1             for indx, pos := range g.entityPositions[1] {                 d := engine.GetDistanceIncludingDiagonal(pos, curPosVector)                 if d < minDist1 {                     minIndx1 = indx                     minDist1 = d                 }             }              g.flowTiles[0][x][y].Direction = g.entityPositions[1][minIndx1].Subtract(curPosVector).Normalize()         }     } }  ``

And my movement code. A lot of code but just basic allignnment cohesion/ separation. With added 2 look ahead vectors to steer away from the collision.

``        desiredDirection := world.Grid.GetDesiredDirectionAt(positionComp.Position, tag)         direction := movementComp.Direction         maxSpeed = movementComp.MovementSpeed          //Avoidance         nearbyEntities := helper.GetNearbyEntities(100, world, index)          avoidance := engine.Zero()         avoidance = avoidance.Add(alignment(world, nearbyEntities, direction).MultiplyScalar(alignmentCoef))         avoidance = avoidance.Add(cohesion(world, nearbyEntities, direction, positionComp.Position).MultiplyScalar(cohesionCoef))         avoidance = avoidance.Add(separation(world, nearbyEntities, direction, positionComp.Position).MultiplyScalar(separationCoef))           //Checking ahead of us whether or not we'll encounter something         lookAheadVectorLong := direction.Add(desiredDirection).MultiplyScalar(maxSpeed * 2.5)         lookAheadVectorShort := direction.Add(desiredDirection).MultiplyScalar(maxSpeed)         maxAvoidanceForce := float32(1.0)          checkPosShort := positionComp.Position.Add(lookAheadVectorShort)         checkPosLong := positionComp.Position.Add(lookAheadVectorLong)          collidedIndexShort := world.Grid.IsPositionFree(index, checkPosShort, positionComp.BoundingBox)         collidedIndexLong := world.Grid.IsPositionFree(index, checkPosLong, positionComp.BoundingBox)          if collidedIndexShort != -1 {             direction = engine.Zero()             avoidance = checkPosShort.Subtract(world.ObjectPool.Components["PositionComponent"][collidedIndexShort].(components.PositionComponent).Position).Normalize()             avoidance = avoidance.MultiplyScalar(maxAvoidanceForce * 1.5)         } else if collidedIndexLong != -1 {             direction = direction.MultiplyScalar(breakingForce)             avoidance = checkPosShort.Subtract(world.ObjectPool.Components["PositionComponent"][collidedIndexLong].(components.PositionComponent).Position).Normalize()             avoidance = avoidance.MultiplyScalar(maxAvoidanceForce * 1.2)         }          direction = desiredDirection         direction = direction.Add(avoidance).Normalize()          positionComp.Position = positionComp.Position.Add(direction.MultiplyScalar(maxSpeed))          positionComp.Position.X = engine.Constraint(positionComp.Position.X, 0, 799)         positionComp.Position.Y = engine.Constraint(positionComp.Position.Y, 0, 511)          movementComp.Direction = direction.Normalize()          world.ObjectPool.Components["PositionComponent"][index] = positionComp         world.ObjectPool.Components["MovementComponent"][index] = movementComp          fmt.Printf("I %d am at %v\n", index, positionComp.Position)     }  }  func limit(p engine.Vector, lim float32) engine.Vector {     if p.X > lim {         p.X = lim     } else if p.X < -lim {         p.X = -lim     }     if p.Y > lim {         p.Y = lim     } else if p.Y < -lim {         p.Y = -lim     }     return p } func alignment(world *game.World, siblings []int, velocity engine.Vector) engine.Vector {     avg := engine.Vector{X: 0, Y: 0}     total := float32(0.0)      for _, siblingIndex := range siblings {         avg = avg.Add(world.ObjectPool.Components["MovementComponent"][siblingIndex].(components.MovementComponent).Direction)         total++     }     if total > 0 {         avg = avg.DivideScalar(total)         avg = avg.Normalize().MultiplyScalar(maxSpeed)         avg = avg.Subtract(velocity)         avg = limit(avg, maxForce)         return avg     }     return engine.Vector{X: 0.0, Y: 0.0}  }  func cohesion(world *game.World, siblings []int, velocity engine.Vector, position engine.Vector) engine.Vector {     avg := engine.Vector{X: 0, Y: 0}     total := float32(0)      for _, siblingindex := range siblings {          avg = avg.Add(world.ObjectPool.Components["PositionComponent"][siblingIndex].(components.PositionComponent).Position)         total++      }     if total > 0 {         avg = avg.MultiplyScalar(1.0 / total * cohesionCoef)         avg = avg.Subtract(position)         avg = avg.Normalize().MultiplyScalar(maxSpeed)         avg = avg.Subtract(velocity)         avg = limit(avg, maxForce)         return avg     }     return engine.Vector{X: 0.0, Y: 0.0} }  func separation(world *game.World, siblings []int, velocity engine.Vector, position engine.Vector) engine.Vector {     avg := engine.Vector{X: 0, Y: 0}     total := float32(0)      for _, siblingIndex := range siblings {         siblingPos := world.ObjectPool.Components["PositionComponent"][siblingIndex].(components.PositionComponent).Position         d := position.Distance(siblingPos)         if d < desiredSeperation {             diff := position.Subtract(siblingPos)             diff = diff.Normalize()             diff = diff.DivideScalar(d)             avg = avg.Add(diff)             total++         }     }     if total > 0 {         avg.DivideScalar(total)     }      if total > 0 {         avg = avg.MultiplyScalar(1.0 / total * separationCoef)         avg = avg.Normalize().MultiplyScalar(maxSpeed)         avg = avg.Subtract(velocity)         avg = limit(avg, maxForce)     }     return avg } ``

What I am trying to achieve is:

Units not mashing into each other and just positioning themselves in a free spot around their target.

What are my problems :

1. Make the flow field direct them away from collision rather than just towards closest unit.
2. Make it work with the current system without adding too many nested loops and awful checks.
3. I am doing the avoidance correctly? I have a desired direction that I get from the flow field (that directs me towards closest enemy), then I add avoidance to it to avoid any other units in the area.

My units move really well up untill the point of collision/ going to a spot next to a target. I am not sure how to implemenent that behaviour yet.

(This is my forth iteration of the movement system. I went from pure boid, to grid based, to A*, to this. So I tried a lot of variations and this going surrounding behaviour has been bugging me every time.)

Custom engine (server) written in Golang and then dispatched to Godot for the visuals. Performance is not my concern, but this is a server, so I am more mindful of that, I could probably brute force it but I’d rather hear some better take on it.

Any suggestion/article/ video is greatly appreciated !!

Edit: Thinking about it, flow field is currently useless. I can basically just have a vector pointing to the closest enemy for each unit… Would be less costly as well. But the problem of them clumping and not knowing how to surround still stands.

## Import from other projects not working properly

@Sven I have four projects set up that I use to clean lists.

Each project is creating verified’s from one of four sold SER lists.

Then, I create a new project for whatever I want to link to.

In the past, when I import verified from other projects all the links would be moved to my new project to build on those targets.

Now SER is filtering or something and not all those links are being brought over.

For example, I have 2400 verified links from today’s cleaning.

But when I import from those projects into the new project, only 408 are copied over.

What’s going on that’s causing that?

## Rotating proxies not working properly

Hello,

I use Metric Checker to get the Google Index metric of website, but when I use rotating proxy the metric value is often 0 when it should not.

Look the attached screenshot for an exemple. screenshot 1 => No proxy loaded and it works, screenshot 2 => rotating proxies loaded and it doesn’t work, i get 0.

I also tried with private dedicated proxy (not rotating) from Buyproxies provider and I had no problem.

Can you help me please ?

PS : I’ve respected the recommanded settings from the Stormproxies and Rotatingproxies websites. (I tried these two providers)

PS 2 : I put these domains in a txt file if you want to try.

https://rotatingproxies.com/support/docs…scrapebox/

## How to properly replicate and archive at once

I have a 300GB database that is growing around 5GB a day. It stores time-based data, and as such, I currently have around 60 days of data. My main database server has a 450 GB NVMe, so I want to get a secondary server that has expandable cheap storage for old data.

The main server only really needs the last 15 days of data. So anything older than 15 days of data I want to move off to the secondary database which has slower but cheap storage. I think standard backup or archiving isn’t viable because I want to query the data at any given moment (maybe ~100 queries a day).

I want to kill two birds one stone here and I thought if I setup replication to the secondary server and then somehow indicate the cleanup stored procedure which delete records older than 15 days doesn’t propagate deletes to the slave.

Is this possible and recommended? If not, what is the best way to accomplish archived the data but to another server and allow querying. I suspect partitioning all of my tables but not all of my tables are time-based so I would need some way to move the time-based partitioned data over along with any FKs needed for it

PS: I won’t be relying on the secondary server as a backup but rather my main replication. I would then do offsite backups of the secondary server periodically

## Mysql: Any way to properly index 3 ENUM columns with the same options ? (A OR B OR C)

I have 3 enum() columns with the same option values inside.
I first tried to use the "set" datatype which originally was meant to do that (hold multiple values from a set) but it seems that datatype isn’t managed for 15+ years and isn’t even supporting an index.
Is there a nice way to index those 3 columns so I can use them in searched without destroying query performance ?

SELECT * FROM TABLE WHERE a=’x’ OR b=’x’ OR c=’x’

I thought about creating a virtual field which uses a boolean logic (&) on the 3 enum field-numbers and combines them into a large number but that’s quite a hack and not nice to maintain.

Has someone solved this sort of task elegantly ? (I do not want to use a support table and JOIN it, I want to stay with a single table)

## Does properly exploring a hex help with Navigation?

I’m currently running Tomb for the first time and have a bit of an odd ask. I’m mainly asking this because one of my players is running a character who’s really into maps and wanting to map the island. If the party succeeds on a proper navigation check for the day and I clear one of the hexes on the map, then say they want to go back exactly the way they came. Do I still need them or their guide to roll a navigation check? Or is that only for when they move into new hexes?

And if the players characters have the map from Syndra Silvane and are trying to fill it in too, does that help them with checks at all?

## How can I properly loop through an array gotten from my wordpress database and display it to my site

I am trying to display some posts information from my database on my live site. I have done the query correctly because I can view the items on the live site. But I need to take three items to display. The post title, the post content which houses the images, and the post id which links to the posts. I seem to have written it correctly but it does not do anything.

This is the code

``<?php      global \$  wpdb;                    \$  results = \$  wpdb->get_results( "SELECT * FROM \$  wpdb->posts WHERE `post_type`='post' AND `post_status` = 'publish' LIMIT    20" );    foreach (\$  results) {       echo "<div class="card">             <div class="img">              <img src="{post_content}" alt="">             </div>             <div class="info">                <h5>{post_title}</h5>             </div>           </div>";   }    //echo "<pre>";print_r(\$  results);echo"</pre>";                      ?>  ``

I am quite new to wordpress and PHP in general.