[solved]Creating a line of X objects between two points

I’m trying to implement a system where I can draw a line of objects (an earth wall) the player can interact with. The player clicks, drags, and releases to create the objects, but I only know how to implement the first and last objects since the player clicks there.

image

I want it to do something like this: every x pixels along the line, create the object. But I don’t know the math or formulas for that.

image

Thanks

An outline on how to achieve this:

To the blocks you want to draw, add a boolean instance variable called IsTemp, and set it to false.

In pseudo-code :

  1. set variable numBlocks = firstObject.DistanceTo(secondObject)/firstObject.width()
  2. set variable count = 0
  3. create normal event:
    . condition is block.Variable(IsTemp) = true
    . action is delete block
  4. create a while event :
    . condition = variable count < variable numBlocks
    . first action is create block at x = lerp(firstBlock.X(), secondBlock.X(), Variable(count) / Variable(numBlocks)), y = lerp(firstBlock.Y(), secondBlock.Y(), Variable(count) / Variable(numBlocks))
    . second action is to set block.Variable(IsTemp) = true
    . add third action to increase variable count by 1
  5. finally create another new event :
    . conditions are mouse is released and trigger once
    . action is set blocks.Variable(IsTemp) = false

Thanks, I got it working