1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Stuck, Having problems with creating your mod? Let us help you: Mod Support
  3. The ingame repository is currently offline for maintenance. Downloading and installing the mods manually via our website will still work: Repository
    Dismiss Notice

texture rotation speed from wheelspeed?

Discussion in 'Programming' started by MRcrash, Nov 1, 2017.

  1. MRcrash

    MRcrash
    Expand Collapse

    Joined:
    Dec 12, 2014
    Messages:
    703
    I´m noob at programming and I would like to have rotating offset discs on cultivator. As this would be very hard to jbeam (and would require good hardware to run), I think best solution is animated texture. But I don´t want it to rotate always, I would like to get rotating speed from rear wheel wheelspeed (which is jbeamed).
    screenshot_00054.png
    I have tried doing a lua but it didnt work. :confused:
     
  2. Nadeox1

    Nadeox1
    Expand Collapse
    BeamNG.Support
    Staff Member

    Joined:
    Aug 5, 2012
    Messages:
    9,971
    I suppose it's a series of planes arrayed?
    Try making them a own mesh and using props for that.
     
  3. MRcrash

    MRcrash
    Expand Collapse

    Joined:
    Dec 12, 2014
    Messages:
    703
    That sounds like a good idea. But I still don´t know how to make them rotate at same rpm as rear wheel/drum.
    --- Post updated ---
    Edit:
    I took beacon.lua and modified it and in works :)
    Code:
    -- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
    -- If a copy of the bCDDL was not distributed with this
    -- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt
    
    local M = {}
    
    local function init()
        electrics.values.discs = 1
    end
    
    
    local function updateGFX(dt)
        local wheelspeed = electrics.values.wheelspeed
        electrics.values.discs = ((electrics.values.discs + (dt * wheelspeed * 320)) % 360) or 0
    end
    
    -- public interface
    M.updateGFX      = updateGFX
    M.onInit      = init
    M.onReset     = init
    return M
     
    Nadeox1 likes this.