Align character to other character

  • #1, by thomas-fringsFriday, 11. June 2021, 12:42 3 years ago
    Es gibt den Aktionsteil "Person ausrichten zu Objekt", aber nicht "Personen ausrichten zu Person". Wie kann man das in Lua programmieren?

    In meinem Fall soll ein NPC nach der Spielfigur ausgerichtet werden.


    English:
    There is an action part "Align character to object", but not "Align character to person". How to program this in Lua?

    In my case I want to align a NPC to the character.

    Newbie

    21 Posts


  • #2, by esmeraldaFriday, 11. June 2021, 14:32 3 years ago
    I guess you would need to check the Position of the current character and according to the y or x position (don't know what your scene looks like) set the direction of the npc

    something like:

    local pos = game.CurrentCharacter.Position

    if pos.x >= 900 then
       Characters["npc"].Direction = 90
    elseif pos.x >= 400 then
      Characters["npc"].Direction = 0
    else
      Characters["npc"].Direction = 180
    end

    I think 0 is down, 90 right, and so on... you would have to check if that is accurate.

    or... you could use action areas. When the pc enters an area set the alignment of the npc accordingly.

    Key Killer

    513 Posts

  • #3, by afrlmeFriday, 11. June 2021, 18:48 3 years ago
    0 is east/right, 90 is north/up. wink

    Click on the compass on a scene object, or one of your character animations in one of your projects & you can quickly figure out the direction degrees.

    Imperator

    7278 Posts

  • #4, by thomas-fringsTuesday, 15. June 2021, 10:43 3 years ago
    Thanks for the help. This is great from you guys! 

    I have added the Y coordinates in the script.

    The action areas can also work out, but in my concept the characters react dynamically and move in the scenery.

    Newbie

    21 Posts

  • #5, by MachtnixWednesday, 07. July 2021, 19:59 3 years ago
    I bin absolut kein Programmierer. I habe es folgendermaßen gelöst: ein Nullobjekt eingeführt und dessen Position immer per Lua auf die Position des Charakters gesetzt. Die andere Person richtet sich immer nach diesem Nullobjekt aus.
    Ich weiß, das ist dreckig programmiert...

    I am absolutely no programmer. I solved it as follows: introduced a null object and always set its position to the position of the character via Lua. The other character always aligns to this null object.
    I know this is dirty programming....

    Thread Captain

    1097 Posts