I have spike enemy that i want to travel in such way as the image…how i can achieve something like that?
You can use raycasting to find what it is standing on and what it is walking towards, which also gives you the normal vector where the raycast hit the wall, then decide when and how to rotate his body to track the ground.
If you have discontinuities like that L-bend you may need some extra fiddling to make it smoothly curve. This can generally be accomplished by tweening between the two normals that you get from the raycast.
Here is an example project (see links in video comments) of following arbitrary 2D colliders. You would need to set up appropriate colliders (perhaps even composite colliders to avoid seams) on your Tilemaps:
1 Like