Was just wondering, is it possible to use RayCast() to get a hit object of any type?
Lets say I have a player. Then I cast a ray. I need to get a hit object for any number of walls or floors, not just one. How can I do this?
I know you could maybe do a hitObject from a collision sensor or Radar, but thats moreso a hack rather than what I am looking for, which is to get the hitObject from the ray hitting said object, which then returns the KX_GameObject of whatever the ray hit, rather than me entering a string or the ray hitting one KX_GameObject.
s = own.worldPosition # start position owner
e = own.worldPosition + own.getAxisVect([0, -100, 000]) # or e = obj.worldPosition in here obj somebody object in scene
ray = own.rayCast(e, s, 0, “”) # ray shot
hit = ray[0] # hit in objects
pos = ray[1] # position ray hit
norm = ray[2] # normal vector in position hit point
if hit:
if “prop” in hit: # filter hit objects with property
obj = hit # work with obj