Hi guys. Are there any (lua?) commands that would allow me to accomplish the following: Create an invisible line sticking out the front of the car that's 'n' units in length. This line/sensor will move relative to the car as if it's stuck to the car (see pic below). Check if any object (vehicle/terrain) is colliding/intersecting with the line. If there is an intersection, return the distance between the start of the line and the closest intersection point. Compare the distance to another number. Do something if a conditional statement is true. Loop back to #2 (This red line represents the invisible sensor stuck to the front of the car) If I'm not mistaken, I believe BeamNG uses something similar to this when you're using the external camera. Basically, I want to check if there's something in front of the car, measure the distance between the car and whatever is within a certain distance from it, compare it to a previous distance measurement, and finally trigger something to happen if a certain condition is met. Is there a more efficient way to achieve this other than what I previously described?
This is in the 0.9 changelog: Exposed new Lua function “castRay”, which can be used in the game engine thread to detect obstacles (will impact performance, use with caution) I think the "external" camera lua uses this for raycasting? Code: be:castRay(self.camPos:toPoint3F(), carPos:toPoint3F())
Thanks! Do you mind if I use and modify some of the code from your Radar Altimeter to accomplish my goal in the first post?
Please note that raycasting in GE lua does not work with other vehicles, so you can't detect other cars. In addition to that, it's not exposed in vlua, making it slightly cumbersome and not very performant to use. I'd recommend a maximum usage frequency of 5 hz, less if possible.
obj:calcCenterOfGravity() return a float3, it's a userdata which means it's a C++ type but you can still use it you create an object like this using float3(1, 2, 3) here is the extract of the class in lua-doc.zip