so if you think of a cube it has 6 sides, to make things easier, you have the front, back, left, right, top, bottom.
hit_normal = ray.hitNormal
ray.hitNormal
this returns a tuple, or a set of values, looks like [0, 0, 0], this “tuple” is what we’ll be using to determine which side of the cube the player is looking at, (the ray sensor is shooting a ray on the positive y axis, this can be shot from the center of the players camera or an object parented to the center of the players camera)
think of the sides of the cube in terms of the global x, y, and z axis. The left and right side of the cube are facing along the x axis, the front and back are facing along the y axis, the top and bottom are facing along the z axis.
this will make things easier
these refer to the sides of the cube, so “front” would mean the front of the cube and so on
front = [0, 1, 0] (positive 1 in the y spot meaning forward on the y axis)
back = [0, -1, 0] (negative 1 in the y spot meaning facing backward on the y axis)
left = [-1, 0, 0] (negative 1 in the x spot meaning facing the left on the x axis)
right = [1, 0, 0] (positive 1 in the x spot, meaning facing the right on the x axis)
top = [0, 0, 1] (positive 1 on the z axis meaning facing up on the z axis)
bottom = [0, 0, -1] (negative 1 on the z axis meaning facing down on the z axis)
so we could say for example
if ray.hitNormal == [0, 1, 0]:
print(“you are looking at the front of the cube”)
do = something appropriate
if you need more clarification, I could set up a little demo blend file for you, it would be some time tomorrow
oh and if you’re trying to find out which side of an object the player is looking at and it isn’t a cube, take a cube, make it invisible. Put the object in the center of the cube, parent the cube to the object. Now you can determine where the player is looking at the object in 3d space.