I need help with head look

I`m making a 3rd person game. I want my character to focus with her head when she
goes past things of interest, like if she sees ammo, she will look down at it or too her side.
How can i set this up, without her head doing the exorcist lol.
Thank you.

ok

step 1 = on frame zero, build a list of all objects that the actor will look at


if 'ListOfLook' not in actor:
    SaveList =[]
    for objects in bge.logic.getCurrentScene().objects:
         if 'LookAtMe' in object:
             SaveList.append(objects)
    own['ListOfLook']=SaveList


step 2 build a list of all objects to look at that are within a range and in a local forward position.

else:
    CloseAndAngle=[]
    for objects in own['ListOfLook']:
         local = objects.worldPosition - own.worldPosition
         local = own.worldOrientation.inverted*local
         
         #dist check
         if local.magnitude<(maxLookdist):
               #angleCheck
               if local.x>0 and) (abs(local.y)-local.x)<=0:
                   CloseAndAngle.append([objects, local.magnitude])

    sortedList = sorted(CloseAndAngle, key=lambda tup: tup[1])       
    ClosestItemInAngle = sortedList[0][0]
    
    # since we know it's inside a angle cone, and it's closest item look at it !              
    
                

later, we can add the code to whatever may spawn in ammo to add it to the master list
(we only build the list on frame zero so anything added after that will need to add itself to the list)

also I will have to add the multi delete code when I get a chance for list cleaning




def multi_delete(list_, args):
    indexes = sorted(list(args), reverse=True)
    for index in indexes:
        del list_[index]
    return list_


if objects.invalid:
    popList.append(objects)


multi_delete(own['ListOfLook'],popList)

tonight, strip out all your textures, and send me a link/google drive whatever and I will take a look at adding anything you need.

do you use a linked.blend to load in your actor?

if you do. then I can just edit that file without needing all your textures/ geometry
(it’s beautiful work! but it will make sending the file back and forth cumbersome*)

Also I only have 4 gigs of ram :stuck_out_tongue:

Do you have skype bpr, im on that now bro. Yeah i will send you a bare bones file, just the female with no textures. I appreciate the help, im still learning how to setup python from scratch
like “Import from bge” that stuff lol.