Hello Unity! I wanted to make a my character latch onto the ridgedbody or hitbox of enemy, and then let go after a certain amount of time. How would I program that?
I'm very new to scripting and have only been studying C# basics so take my solution with a grain of salt. I'm 100% certain there are better ways and hopefully someone will come along and offer one of those. Until then, here's what I'd do with my basic knowledge. At OnTriggerEnter2D, I'd find the X,Y position difference between the character and the enemy and then set the character's position at that difference until released. I'd start a simple timer by accumulating Time.deltaTime and once I reached my desired latch on duration I'd return to my standard character position code. Remember, this could be a terrible solution!