If CHARACTER is ALIGNED Function

  • #1, by PykeSaturday, 27. September 2014, 15:23 11 years ago
    Hey guys,

    I would love to have an 'If CHARACTER is ALIGNED' action part so that I could call certain actions if the character is facing a certain direction.

    I can think of hundreds of uses for this, from puzzles to just adding in little character details!

    -Chris

    Newbie

    59 Posts


  • #2, by kokaloSunday, 28. September 2014, 13:26 10 years ago
    Hi there,

    You can access the direction of the character using LUA with something like game:getLink(VGameCurrentCharacter):getInt(VCharacterDirection).

    You could then create a value in your character and have a main loop function update the value.

    Im just starting to use VS so there are probably more/better ways to do it.

    Newbie

    1 Posts

  • #3, by AlexSunday, 28. September 2014, 13:54 10 years ago
    Hi Chris,

    you're right - an action part would be useful for this. I'll add it after the next release (because it needs more time to test, translate labels, etc.).

    Great Poster

    378 Posts

  • #4, by PykeSunday, 28. September 2014, 23:22 10 years ago
    This is why I love Visionaire - its actually constantly being developed and improved! You guys take all the community suggestions seriously and implement them - and it really shows. The engine works in a production environment, because the features being added are things that developers are actively using!

    I know I'll be using Visionaire for a very VERY long time!

    Now about that 4.1..... grin

    Newbie

    59 Posts

  • #5, by AlexWednesday, 01. October 2014, 13:24 10 years ago
    I know I'll be using Visionaire for a very VERY long time!

    good to hear smile

    I've started implementing the action part but I'm already facing a problem: let's say the character walks to the left and a few pixels upwards. Because the character mainly walks to the left the left animation is shown. Internally the character direction is e.g. 172°. How do you want to query this direction? should the character direction be mapped to 180° degrees because the left animation is shown (so you can test for 180° degrees)? this won't work for 3d-models because the character is shown for the exact direction.

    I think the best solution would be to add a range value (or whatever it should be called) to the action part. For example you'd query for 'Is character aligned to 180° (+/- 10°)'. The test would be true if the character direction is between 170 and 190°. Would this be ok?

    Great Poster

    378 Posts

  • #6, by PykeWednesday, 01. October 2014, 14:04 10 years ago
    The script I'm currently using uses a range and it works perfectly.

    if dir >= 0 and dir <= 44 then
    startAnimation("Characters[" .. char:getName() .. "].CharacterOutfits[" .. outfit ..

    Newbie

    59 Posts

  • #7, by afrlmeWednesday, 01. October 2014, 14:38 10 years ago
    Couldn't you query the amount of directions the character has & then you divide 360 by the amount of directions to get the range & then you add the range values to a table.

    i.e: character has 8 directions which means that the range is 45º per angle & right (east) starts on 0º, so...
    t[1] = {rs = 0, re = (t[1].rs + (range - 1))}
    t[2] = {rs = (t[1].rs + range), re = (t[2].rs + (range - 1))}
    etc...
    

    I'm not sure how you would implement it in c++, but I think it could work as long as you query if it's the initial table entry, inbetween entries or the last entry so that you can adapt the code as needed.

    Imperator

    7285 Posts

  • #8, by AlexWednesday, 01. October 2014, 15:33 10 years ago
    as mentioned above this doesn't work for 3d models. I think it makes more sense if the action part works for all characters. therefor I'd add a range value to the action part, either as range from-to or range +/-, e.g.

    if character is aligned between 20° and 30° then
    ...
    if character is aligned to 25° (+/- 5°) then
    ...
    I guess both 'formats' have its advantages/disadvantages (depending on the use case) but both should be easily usable. So I assume it doesn't matter that much which one I'll implement (unless someone of you complains wink ).

    Great Poster

    378 Posts

  • #9, by afrlmeWednesday, 01. October 2014, 15:59 10 years ago
    Aye I guess your method makes more sense. I mis-read what you wrote. smile

    Imperator

    7285 Posts