Trying to teleport, can't find out how to! :D

Discussion in 'Programming' started by krallopian, May 23, 2019.

  1. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    790
    Basically trying to work out how to trigger sounds in the game. I don't want them to play over the game, just IN the game.

    Turns out adjusting their volume doesn't do the trick, it APPLIES the new volume, but it doesn't actually affect it in the game. Only MOVING the soundEmitter does. So, how about I just do something like, "move position X + 0.01" however I can't figure out what the code is for positional movement.

    This is my script currently for testing purposes anyway:

    Code:
    local function lane2(kdata)
    if kdata.event == 'enter' and kdata.triggerName == 'dragLane2' then
    print("hello");
    local soundT1 = scenetree.findObject("testSound1");
    print(soundT1);
    soundT1.volume = 0;
    end
    if kdata.event == 'exit' and kdata.triggerName == 'dragLane2' then
    print("goodBye");
    
    local soundT1 = scenetree.findObject("testSound1");
    print(soundT1);
    soundT1.volume = 1;
    
    end
    end
    lane2
    --- Post updated ---
    Triggering, "is3D" and "maxDistance" etc also works but it doesn't actually affect the sound being played, but you can see the affect happening in the engine.
     
  2. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    Hi!

    You can find or set the position of a lot of objects in the game with :getPosition() or :setPosition(). Using your variable:

    Code:
    local pos = soundT1:getPosition()
    soundT1:setPosition(Point3F(50, 50, 100))
    soundT1:setPosition(pos)
    Those should work, you'll see the new placement of the emitter in the editor. I can go into a lot more detail with this; you can convert that position to a vector with vec3(pos), and back to a Point3F with vec3(50, 50, 100):toPoint3F(). There's lots to explore with position manipulation.
     
    • Informative Informative x 1
  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