wallrun or object magnetized to wall

Need a help with scripting.

This concept is from a friend and the design is fairly simple for the moment.
Only including jump, WASD and Shift.

What we concern at the moment is making and object “stick” to any walls or surface in front of them…
And then as they move, they’ll be magnetized or gravitate to the object’s shape and trail along it as long as we hold shift.

This is a core mechanic and we’re in need to solve it.

Here’s a diagram and concept to help you.

The basic variables need only be movspeed.
Any thing else will be a product based on it.

try using OnCollisionEnter, from there, for each collision contact, cast a ray on that direction on a certain layer (to avoid unwanted weird behaviour on unwanted surfaces) and after that use movspeed on the y axis of the tangent vector (use tangent cause it will allow you to wallrun on curved surfaces).

after that, use a timer (use as grip) which it will allow you to start and cancel the time of action (something like → while(timer < gripTime) or you can use → if(timer < gripTime)

and after that, in the while transition use transform.position = Vector3.MoveTowards(transform.position, yourRayCastHit.point, yourTime or movSpeed);

anyway, hope that helps, if not just send me a message: