Slope dedection

I found slope dedection answer in the unity answer just want to know how rotate the a character in 2d according to slope

var slope = hit1.normal;
transform.rotation = Quaternion.FromToRotation(transform.eulerAngles, hit.normal) * transform.rotation;

but this doesent seems to work on 2d

hmm, well my understanding 2D physics is limited i usually default to 3D and restrict the Z perhaps u could do this as a last resort.
also i’ve noticed u have hit1 for the name of your raycast but this section

transform.rotation = Quaternion.FromToRotation(transform.eulerAngles, hit.normal) * transform.rotation;

you have it written as hit not as hit1, is this intentional?

secondly the values for FromToRotation are direction values ie
below would turn the object from facing forward to facing backwards.

 transform.rotation = Quaternion.FromToRotation(transform.forward, -transform.forward); 

hopefully this helps, its been a long time since i used JS so my knowledge is limited, appologies for the long winded answer wanted to make sure i covered everything, lastly if it doesn’t work
i recommend using some debug.logs similar to the following to determine whether your values
are being set correctly.

Debug.Log(hit1.ToString());
Debug.Log(hit1.transform.position.ToString());