Is there a way of stopping the laser from going through the plane?
See, I’m trying to have it where once it comes into contact with an object, its size decreases as the laser moves closer to the object. A good example is in the game Resident Evil 4(don’t know if anyone’s played it). The character’s weapons have lasersights that appear to decrease in size when he moves closer to the object its in contact with.
The size, I believe, could be solved with a simple size IPO on the Y-axis, but figuring out how to set it up is the problem. The empty is supposed to be used to add an effect like water splash, dust, smoke, etc. depending on what surface its in contact with.
You would need python to determine the distance between the two object. That can easily be done with a raysensor.
GetPosition() gives you the position of the object casting the ray.
GetHitPosition() gives you the position where the ray hits the target.
Now you could determine the distance with the formula sqrt( xx, yy, z*z). See the example in the previous post.
You can use the distance to set the IPO scale. I’m not sure if you could work with float here.
Another way would be to set the orientation matrix ( setOrientation() ) to perform the scaling. The orientation matrix would be following:
[[scale, 0, 0],
[0, scale, 0],
[0, 0, scale]]
Where scale is the distance from above. Be aware this removes any rotation!