Change distance parameter to NPC / Entfernungsparameter zum NPC ändern

  • #1, z thomas-fringsSunday, 13. February 2022, 12:46 hodinky 2 years ago
    When interacting with an NPC character, the main character runs to that NPC and automatically keeps a distance from the NPC. Probably this is a set parameter in the engine.

    Is it possible to override this via Lua script so that the main character does not keep a distance to the other person and stands very close, for example?

    Deutsch:
    Wenn man mit einem NPC-Charakter interagiert, läuft der Hauptcharakter zu diesem NPC und hält automatisch einen Abstand zum NPC. Vermutlich handelt es sich um einen eingestellten Parameter in der Engine.

    Kann man per Lua-Script dies überschreiben, dass der Hauptcharakter keinen Abstand zur anderen Person hält und zum Beispiel ganz nah steht?

    Bažant

    21 Posts


  • #2, z afrlmeSunday, 13. February 2022, 13:35 hodinky 2 years ago
    A'llo, unfortunately the wiki is currently down so I can't be sure, but I believe it's the ActionDestPosition data structure table you need to edit.

    Characters["Tom"].ActionDestPosition = {x = 100, y = 100}


    Alternatively you could offset from their current position instead if you don't want to use absolute coordinates (maybe for dynamic purposes).

    local char = Characters["Tom"]
    
    local pos = char.ActionDestPosition
    
    char.pos = {x = pos.x + 100, y = pos.y + 100}


    The example above should offset the interaction position to be 100 pixels to the right of & 100 pixels below the specified characters current position on the scene - position is based on the animation center you assign to each of the characters animations.

    Quick note: If your npc are always in a fixed position in a single scene, then you could actually set the default interaction position for the character inside of the properties section for the character via position for executing an action.

    Imperátor

    7285 Posts

  • #3, z thomas-fringsMonday, 14. February 2022, 10:41 hodinky 2 years ago
    Thanks for the quick reply!

    I changed the code a little bit, because the error "Unknown data-field "pos" for object (0,1)" appeared with the code.

    Here is the changed code, with which it works:

    local char = Characters["Tom"]

    local charPos = char.Position

    local pos = char.ActionDestPosition

    Characters["Tom"].ActionDestPosition = {x = charPos.x + 100, y = charPos.y + 100}

    Bažant

    21 Posts