P
P
PopTop2021-08-04 10:52:59
Unity
PopTop, 2021-08-04 10:52:59

How to make death when falling relative to your coordinates?

Hello, I know how to make death when falling when reaching certain coordinates along the Y axis, but how to make the character climb up the platforms jumping from point 0 along the Y axis, for example, 2m along Y, to die if he does not jump onto the platform and returns back to side of the original, let's say 1m below its peak along the Y axis? Total from point 0 jumps to 2 without clinging falls to 1 and dies. I found the only more or less similar one, this is death during acceleration, but this is too complicated for me and it seems to me that in my case it will not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2021-08-04
@dollar

Why find? Think up.

Offhand solution:
У персонажа должно быть два состояния:
1) когда он на платформе
2) когда он в воздухе (т.е. летит)
Таким образом, как только персонаж каким-либо образом оторвался от платформы (прыгнул или шагнул с края), в этот самый момент нужно запомнить координаты и привязать к персонажу. Например, в переменной lastGroundPos
Дальше, надеюсь, всё очевидно. Как только перс приземлился, считаем разницу координат по Y, и либо вычитаем здоровье, либо убиваем, - что душе угодно.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question