Hi y'all, So I'm trying to develop an UI app to display the displacement of a coilover in real time; a coilover is just two nodes joined together with a beam in the Jbeam file, so I'm thinking the most straightforward approach would be to just display the length of this beam. The vehicle would drive through corners, run over bumps, and the UI app would show the displacement in real time. Then I did some reading into the Streams function, and didn't find anything regarding suspension data. So would I be able to add a stream that spits out the beam length data, or a stream that outputs the position of the two coilover nodes? (I'll calculate the length outside of BeamNG) And any ideas on how to approach this? Sorry if I'm mixing up some functions/concepts
Obj:getBeamLength(cid) - current distance between nodes Obj:getBeamLengthRefRatio(cid) - ratio between the current and starting distance between nodes (with precompression) Obj:getBeamLengthRestRatio(cid) - ratio between the current and starting distance between nodes (no precompression) Obj:getBeamRefLength(cid) - starting distance between nodes (with precompression) Obj:getBeamRestLength(cid) - starting distance between nodes (no precompression)
Another quick question: So I'm implementing the Obj:getBeamLength(cid) function on the front left coilover of my vehicle, but I'm having difficulty finding the correct value for cid. The front coilover is defined as nodes "sf6","a9" and has its name defined as "name":"damper_FL", but both these values do not work when placed directly in Obj:getBeamLength(cid). Where would I define the cid? Thanks!
Each beam has its own cid that is invisible on the Jbeam side, you need to make a loop through all beams of the vehicle and find the cid manually, for example: Code: local yourCid = nil for _, b in pairs (v.data.beams) do if b.name = "damper_FL" then yourCid = b.cid end end
I see, no wonder the LUA didn't throw out any errors when I put a random number in the cid field. I tried putting 1 just for giggles, it ran with no issues but I had no way of seeing which beam was 1.
So the beam name approach ("name":"damper_FL") seems to be a dead end. The loop doesn't seem to be able to find the damper's beam, and the cid values keep coming back as nil. I've tried to approach this by comparing the node names, but so far no luck. Code: for _, beam in pairs (v.data.beams) do if beam.id2 == "a9" and beam.id1 == "sf6" then yourCid = beam.cid end end Does anything look off?