direct a raycast from point a to point b

hello everyone, i am attempting to make a space shooter game, and thought of adding solar pannels to the spaceships, that way people cant hide in a behind an object forever to prevent death. so the best way i could think of doing this is by using a colider on the light to detect when an object is in range to actualy be able to charge from the light and a raycast to be casted from the light to the spaceship`s solarpanel position do detect if there is something in the way. so my question is how do i input the direction to the raycast if i only have 2 positions?

thanks for the help everyone.

p.s. i did not include code simply because i did not think it would be nessesary to answer the question, but if its needed pls tell me and i will repost the question with code

Use Linecast instead of Raycast.

To get a vector from one position to another simply subtract the source from the destination.

Vector3 fromPosition = source.transform.position;
Vector3 toPosition = destination.transform.position;
Vector3 direction = toPosition - fromPosition;

The same principle applies to any type of vector.