i was wondering if the was a way to get the distance between the center of an object, and the ray’s hitpoint. is this even possible?
rayCast() returns 3 values: the object hit, the location of the hit[x,y,z] and the normal of the face hit, it can also optionally return the polygon as well. getDistanceTo() can take either a game object or a list [x,y,z]. Hopefully the code below works, I’m at work, so can’t test it.
ob, hitPoint, normal = rayCast(toSomething, own, 1000) distanceToHit = own.getDistanceTo(hitPoint) print distanceToHit
Alternatively, since rayCast returns a game object and getDistanceTo takes a game object you can do it this way:
ob, hitPoint, normal = rayCast(toSomething, own, 1000) distanceToHit = own.getDistanceTo(ob) print distanceToHit
Hope this helps!
If you’re using a ray sensor you can just get the name of the sensor and use the hitPosition property, then use getDistanceTo() to figure the distance between the player’s position and the position spat out by hitPosition.
ok iv’e got it figured out now, thanks a bunch!