Unsolved castray

Discussion in 'Mod Support' started by fillman86, Feb 12, 2024.

  1. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    173
    I know this is inefficient but luckily that is besides the point of what I'm doing lol

    I'm trying to figure out how to use castray to get one node's position and getting it to project along a vector in the direction of another node. The node positions I can get, but my lack of coding knowledge is showing, and I can't find out how to cast a ray with this information

    I've even tried to copy some code from official mods, but no matter what it throws an error saying "attempt to call global 'castRay' a nil value" (or castRayStatic for testing if I get a different result)

    what I'd love is someone to either direct me to clear documentation for idiots like me, or make a simple example controller lua file that gives a distance to the ground for reference

    (I was directed to the avro arrow in searching for info, but I couldn't understand how they used it, and couldn't even retrofit it to my own thing)
     
    • Like Like x 1
  2. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    173
    alternatively someone could write the documentation for this
     
    • Agree Agree x 1
  3. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    173
    alternatively if a dev does make the documentation for this, can they please link it here when it's done. As for now I'm going to give up on this
     
  4. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    60
    To get distance to the ground I used 'be:getSurfaceHeightBelow(vec3(x, y, z))' function. It helped me to implement into my latest mod the 'teleporting to the ground level' option (a player clicks the button and the vehicle teleports to the ground level)
     
    • Like Like x 1
  5. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    173
    hmmm not quite what I wanted, I need it to be on a specific trajectory. Alternatively if it was instead "getNearestGround" or similar it'd work, otherwise things like banking wouldn't work as intended.

    it'd be close, but I present things in a very specific way in my videos, and I like to be fastidious about -certain- things. Not to mention that there's other situations where I've needed to know how to use castray, and I still can't figure it out
     
  6. Disnejar

    Disnejar
    Expand Collapse

    Joined:
    Jun 9, 2024
    Messages:
    1
    As far as I understand your code is on the vehicle, so maybe you can use obj:castRayStatic?
     
  7. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    60
  8. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    173
    I've not looked much into raycast as it seems to be only mouse orientated as far as I can tell. Since posting this though, I have learned more about how to get nodes, and beams into lua, so maybe I'll be able to look at doing this again.

    one other thing I learned is that I am unable to use anything in beamng.tech (as far as I'm aware), so that kinda sucks or I'd set it up like a lidar
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice