c ++ – Problem encountered when using a dynamic array on multiple instances of a class

I managed to get an A * tracking search algorithm on my game and I want all the enemies to behave according to their path, but only one at a time can follow its path and the others get stuck in walls.

Here's how I made it work:

Node * navMap = nullptr;

Node * dynamicArray = new node[dynamicArraySize];

  • I then return dynamicArray, so far, I think navMap = dynamicArray, is not it?

  • I pass as a navMap argument to a findPath function that gets the following parameter: Table of nodes[]

  • I run my code that uses a lot of references and pointers to elements of the array.
    When there is an entity, it works well, but when there are several, it becomes complicated.

I've tried to create a separate node dynamic array (called m_NavMap) for each instance of the class, but obviously when I do it m_NavMap = navMap the result is the same since navMap is a pointer.

I really do not see how to solve this problem, no idea?