P
P
Pragma Games2022-01-14 13:47:18
Mathematics
Pragma Games, 2022-01-14 13:47:18

How to position the enemies at the points of the parabola?

Hello. I liked the mechanics in one game, I'm trying to implement it (wave-like movement of blocks behind the character). I was able to repeat it, only my blocks deviate linearly, and in the screenshot, as far as I understand, one branch of the parabola (Immediately, the offset is small, then it increases). I would like to see a formula by which you can find the points where the blocks should be located. Now the code looks like this:

// Позиция в которой располагается текущий блок
            var nodeStoragePoint = _storagePoints.First;
            
            // i используется для того что бы предать смещение блоку
            for (var i = 1; i <= _storagePoints.Count; i++)
            {
                // _blockStoragePoint точка за спиной игрока от которой начинаются блоки 
                // по y блоки не двигаются, позиция по y задается при подборе блока и после 
                // не изменяется
                var x = (_blockStoragePoint.position.x - nodeStoragePoint.Value.position.x) / i;
                var z = (_blockStoragePoint.position.z - nodeStoragePoint.Value.position.z) / i;
                
                nodeStoragePoint.Value.position += new Vector3(x, 0f,z);
                nodeStoragePoint.Value.rotation = _blockStoragePoint.rotation;

                nodeStoragePoint = nodeStoragePoint.Next;  
            }

            MoveBlocks()
            {
                   // Движение блоков к своей точке через изменение позиции в moveTorwards
            }

61e151cda2345808450252.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2022-01-14
@hint000

It does not look like a parabola (the perspective here is kind of wild, but still the shadow from the top of the parabola could not be so direct (in other words, I see some kind of asymptote here)). More like x=a+b*atan(c+d*z) (you need to match a, b, c, d).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question