I'm trying to simulate laserbeams going through movable mirrors to see where they end up on some screen depending on the orientation of the mirrors. So I figured that I could use raycast from the laser source to the mirrors and from the location and normal vector of the mirror cast a new ray in the reflected direction an so on.
But I can't get the raycast to work. I have previously used the raycast from 3Dview to objects from the template with success. But I can't find any good explanation or documentation on the basic object.ray_cast() function.
import bpy
import mathutils
source = bpy.data.objects.get('Source')
location = source.location
direction = mathutils.Vector([0 , -1 , 0])
ray_succes, ray_object, ray_normal = source.ray_cast(location, direction)
But I get this error:
So I lack the basic understanding of how the function works. Any explanation, good answered questions, tutorials, documentation would be really appreciated. I'm open to alternative ways to shine light beams through mirrors which I can then move and rotate with python code.

Object.ray_casthas for a long time returned a tuple of 4 results,as shown inOperator Modal View3D Raycasttemplate, these aresuccess, location, normal, face_indexThe error (please copy & paste as text from system console in future) displayed is informing you that you only have 3. Hence Question Closed as dupe.. Somewhat related https://blender.stackexchange.com/a/91019/15543 – batFINGER Mar 08 '21 at 17:06