at first I saw that 2.46 had this command, and I was pleased that I didn’t need the extraneous logic bricks.
but then I realized that I’m probably not going to use it at all: there’s no way to get anything other than the object hit. without the ability to get the hitPosition, hitNormal, etc. that one can get from the logic brick ray, does this function really have a use? I suppose a barebones shooting script might still use it to see IF the gun hits and deal damage, but you can’t use it to orient a character to the slope it’s on, or place a bullet spark, or pretty much anything I’d use a ray for.
additionally, I’d love to be able to cast the ray from anywhere as well as to anywhere, the only option at the moment seems to be using an empty that I reposition based on where I want to cast from…
…as irritated as this post may seem, I’m still very pleased and grateful that someone took their time to improve the BGE, I just hope that it can continue to get better.
I wrote this function with a specific application in mind (path finding) but it can easily be extended to support shooting method with largest flexibility. The information that you need is available but not returned.
What about returning a tuple (Object,hit_position,hit_normal) and taking an additional parameter to specify the from point? Probably make it a different function to keep the simple functionality in rayCastTo()
you could, if so inclined, make it return just the object by default but if one specifies an optional parameter, as in rayCastTo(1), it returns the tuple. or you could just make a separate function, if it’s easier. either way, I’d be really happy ^^
I’ve added a rayCastToEx() function with full flexibility on origin/destination that also returns hit point and normal. You don’t need ray sensor anymore
btw, since the new rayCast() fuction can return the HitNormal, i will adapt my normal alignment function to cast a ray without needing to setup a ray sensor (maybe as an actuator)
Hi all,
I have found a new version to use your rayCast() function, but there are some unhandled error (“SystemError: erro return without exception set”) when using the parameter “prop” (for “property” of the first object to reach).
Could it be fixed?