Instantiate object on top of hovered object

Hello,

I want that in the moment I hover my mouse over the object, a divine ray of light to shine on top of the object.
In translation, I want to instantiate the godly_ray object over the object my mouse cursor is currently hovering.

I know how to do this with ray casting and using the hit colider, but how about when OnHover ?

void OnMouseEnter()
{
		clone = Instantiate(prefabObject1, Spawner1.transform.position , Spawner1.transform.rotation) as GameObject;
}

If you’re saying you have a script on each object you’re hovering over, which is probably true if you’re using OnMouseEnter(), simply use transform.position to get the position of that object. Otherwise, the only other thing I can come up with is to use one single script on some empty gameObject that you could name “Scripts”, or on the main camera. This way you could use raycast like so:

Ray ray;
RaycastHit hit;

void Update()
{
    ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    
    if(Raycast.Physics(ray, out hit))
    {
        Vector3 hoverPosition = hit.collider.transform.position;
    }
}

Keep in mind this is a very basic example, not an actual script.

You could give the divine_ray_of_light prefab a script, and that script contains 2 things.

1, a var that stores the transform of the object that caused the instantiate of this divine ray prefab (the thing it needs to shine on).
2, a constant transform.position update to equal the location of the transform stored in that variable from point 1, but with a offset on the Y axis to make sure it is always on the right height.