A question about making spells(magic)

Hello there, I am trying to create a spell for my game that will basically do this:
while the player is moving, the spell leave a trail of something that will give damage to enemies while they are standing on it (something like this: Shyvana Ulti)

So I am currently doing this: When the spell is activated, I take my player’s position in a variable and controlling the distance between that position and player’s current position. So basically, I instantiate a prefab(that is my spell) to world for every x unit my player moves on

As code:

void Update () 
    if (Vector3.Distance(sneakAttackDropPos, transform.position) > sneakAttackDropDistanceConst) 
	sneakAttackDropPos = transform.position;
	Instantiate(sneakAttackFX, transform.position, transform.rotation);			

When I press [space] my sneakAttackDropPos is filled with my transform.position.
sneakAttackDropDistanceConst this variable is the value of on every x units of my player moves, the spell should be instantiated, so its 1.5f and on every 1.5f unit of my player movement it instantiates my spell.

This works quite fine and as expected but here is the problem: I don’t want my player to instantiate my spell on the ground where there is already a spell on it. Basically I don’t want sneakAttackFX to be instantiated on same locations.

What have I tried to fix the problem: Controlled OnTriggerStay and OnTriggerExit in a script that has been attached to my sneakAttackFX object. So if my character is OnTriggerStay of my sneakAttackFX object, I false’d a variable and if that variable is false, my Instantiate will not work on player object, this has led to unexpected thus no good solution.

I have nothing else in my mind to fix this problem, so I am asking you this:

  1. If this is a good way of doing something like this
  2. If there is any, what are better options that can yield better results?

Thanks in advance.

I think you are on the right track, but I would not use any onTrigger or collision checks.

What I would do:

  • Activate spell.
  • Now check distance to spell
  • If distance is > constant, drop new spell
  • Now check for all spells

Basicly check distance to all spells positions stored in an array of some kind. Let me know if you dont know how that works.