A
A
Alexander Kovach2021-10-01 15:24:52
Unity
Alexander Kovach, 2021-10-01 15:24:52

How to implement underfoot shadow mechanics for better player positioning in 2d platformer?

I want to make a 2d platformer on unity. Under the feet of the character should be a dark oval (such as a shadow), which decreases when jumping, disappears over the abyss and traps. This should serve to better position the character in the air. How it is better to implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bogdan Erolskiy, 2021-10-01
@AleksandrKovach

It seems to me that it's worth it to simply create an object under the character. Attach a shadow image and a script to specify the logic of the shadow operation on it.
The script will track the location of the character and, depending on the value along the Y axis, change the localScale of the shadow.
Also, add the logic of hiding the shadow to the script when the character is close to obstacles.
Good luck in development!

N
Nekit Medvedev, 2021-10-06
@NIKROTOS

We set the shadow gravity (it itself falls on the desired object). Change the shadow depending on the distance to the unit. (If the unit is in a state of flight)
During the jump, do RayCast down, if the object has changed, move the shadow to the player, it falls again.
It is necessary to choose the value of gravity, so as not to see the fall.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question