Help python BGE get object


Is it possible to get objects by part of the name?
if have 2 objects ‘Slider1_Top’ and ‘Slider2_Top’
i need to make a dynamic script so for each object the same script (Not for each object antoher script)
i tried ‘scene.objects[“Slider”, num, “_Top”]’ (Num is an int)
But that doesnt work.

  • winspeednl

Sure it is possible. The build-in method with objects[<name>] is not a good search. There is just one criteria (the name) and it does not tell you if there is more than one object matching the search criteria.

Better implement an own search:

def findByNamePrefix(objects, prefix):
  return [object for object in objects if]


Thanks both of you.
But is it possible to get the object where the script is running on?
then get the children of that object?

own = cont.owner()

It says he does not know cont.owner()

solved it was cont.owner

It works :slight_smile:

own = cont.owner
Slider_Top = own
Slider_BG = own.children[0]