How to implement a Shadow Leap(DARK like feature)?

Hi,

Im creating a game similar to Kalypso Media’s Dark. This game has a feature called the Shadow Leap.
The feature is shown in detail in the video below:

so i want to make a similar feature. I have already created the script for it and everything is fine regarding the player movement but i cant get the targeting UI to work. I used ScreenToWorldPoint but it doesnt work properly. In Dark, when you press a button, the target UI appears and if you move your mouse it slides on the floor. In my case, the target UI goes through objects. I tried getting raycasts and surface normal detection working but i have the same result. Any help as to what would make this work is greatly appreciated.

My script:

using UnityEngine;
using System.Collections;

public class ShadowDash : MonoBehaviour
{
public float smooth;
public GameObject ui;
public bool shadowDashButton;
private RaycastHit lastHit;

// Use this for initialization
void Awake() 
{
	shadowDashButton = false;
}

// Update is called once per frame
void Update ()
{
    ui.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10) + lastHit.normal);

    if (Input.GetKey(KeyCode.Q))
		shadowDashButton = true;
	else
		shadowDashButton = false;

	if(shadowDashButton)
	{
        ui.SetActive(true);

        
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);

		if (Physics.Raycast (ray, out lastHit))
		{
            if (Input.GetKeyDown(KeyCode.E))
                 {
                    StopAllCoroutines ();
				    StartCoroutine (Motion1(lastHit.point));
                }
		}
	}
    else
    {
        ui.SetActive(false);
    }
}

IEnumerator Motion1(Vector3 position)
{
	float t = 0;
	while(t < 1)
	{
		t += Time.deltaTime;
		transform.position = Vector3.Lerp (transform.position, position, Time.unscaledDeltaTime * smooth);
		yield return null;
	}
}

}

It looks like they’re just using a particle system and taking the hit point from a raycast (originating from the center of the screen, not the mouse position. its actually the camera movement that’s changing the position) and lerping the position of the particle system from its current position to raycast hit position.

Use the surface normal of the raycasthit and use quaternity.lookrotation(hit.normal) to constantly update the rotation.

public class TargetUI : MonoBehaviour {
    public GameObject particle;
    void Update() {
        if (Input.GetMouseButton(0)) {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RayCastHit hit;
            if (Physics.Raycast(ray), out hit)
               particle.setActive(true)

            particle.transform.position = Vector3.lerp(particle.transform.position, hit.point, 1*time.deltatime;

           particle.rotation = Quaternion.LookRotation(hit.normal)
        }
    }
}

I didn’t write this in a compiler so forgive any syntax errors

Hope this helps