TSStatic question

Discussion in 'Programming' started by bostonjay, Aug 17, 2022.

  1. bostonjay

    bostonjay
    Expand Collapse

    Joined:
    Oct 21, 2021
    Messages:
    2
    I'm working on a scenario and I'm able to create a TSStatic object by placing the code in a scenario prefab file, and that works fine, but when I create it in Lua using the same code, the object's collision is turned off and vehicles pass right through it. The weird part is that I can fix it if I go into the World Editor, inspect the object, select the collisionType pulldown, and then exit back to the scenario.

    Anyone know how to create solid TSStatic objects in Lua?


    Here's the code, I've tried many variations, and nothing seems to fix it:


    local TS = [[if(isObject(gngtest)) {
    gngtest.delete();
    }

    new TSStatic(gngtest) {

    shapeName = "/levels/west_coast_usa/art/shapes/objects/constructionbarrier.dae";
    dynamic = "0";
    playAmbient = "1";
    meshCulling = "0";
    originSort = "0";
    useInstanceRenderData = "1";
    instanceColor = "White";
    instanceColor1 = "White";
    instanceColor2 = "White";
    collisionType = "Collision Mesh";
    decalType = "Collision Mesh";
    prebuildCollisionData = "0";
    renderNormals = "0";
    forceDetail = "-1";
    position = "12.051 1633.611 99.73";
    rotation = "1 0 0 0";
    scale = "1 1 1";
    rotationMatrix = "0.46978116 0.872844696 -0.132090926 -0.877663136 0.477890313 0.0364476368 0.0949381068 0.0988088921 0.990567267";
    isRenderEnabled = "false";
    mode = "Ignore";
    canSave = "1";
    canSaveDynamicFields = "1";


    };


    SimGroup.add(gngtest);


    ]]

    TorqueScript.eval(TS)
     
  2. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    414
    I think the issue is that it doesn't recalculate collisions for the level, but presumably it does when you select the collision type in the world editor.

    I wonder if spawning a new vehicle and then despawning it would trigger a collision recalc. Or perhaps there is a lua command for recalculating/refreshing collisions.

    Sorry can't help beyond that.
     
  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