VAnimationCurrentPosition trouble

  • #1, by foremmaSunday, 03. August 2014, 23:38 11 years ago
    I'm trying to find the position of an animation using this, but whenever I run my game in the editor I get this error:
    16:31:47: Warning: Tried to access invalid field. Field AnimationCurrentPosition (id: 496) does not exist in table Animation (id: 182).
    16:31:47: Warning: TDataGroup::GetValue: Cannot find field in object: AnimationCurrentPosition

    Here's my code:
    local anim = getObject("Animations[Animation0]")
    startAnimation(anim)
    local getAnimPos = anim:getPoints(VAnimationCurrentPosition)

    The animation plays, but I get that error...What am I doing wrong? just found VAnimationCurrentPosition from looking around at various threads on here and the Visionaire wiki, so maybe I am using it incorrectly?

    Newbie

    32 Posts


  • #2, by AlexSunday, 03. August 2014, 23:52 11 years ago
    yes, you're using it incorrectly. the field only exists for active animations (ActiveAnimations table), see Data structure and startAnimation documentation. Further the field is a point and not a point list (use getPoint instead of getPoints method).

    to put it all together your code should look something like this:
    local anim = getObject("Animations[Animation0]")
    local activeAnim = startAnimation(anim)
    local getAnimPos = activeAnim:getPoint(VAnimationCurrentPosition)

    Great Poster

    378 Posts

  • #3, by foremmaSunday, 03. August 2014, 23:56 11 years ago
    Wow, thank you so much, worked perfectly

    Newbie

    32 Posts

  • #4, by afrlmeSunday, 03. August 2014, 23:58 11 years ago
    it's getPoint not getPoints.

    The animation has to be active to return or set the animation current position.

    Question: are you running this script via a function in the script editor or via an execute a script action? local variables are not much use in scripts executed via the execute a script action part unless everything is sorted out in that single execute a script action.
    startAnimation("Animations[Animation0]")
    pos = getObject("ActiveAnimations[Animation0]"):getPoint(VAnimationCurrentPosition)
    
    print("x = " .. pos.x .. ", y = " .. pos.y) -- prints out x & y positions of linked animation.
    

    .. as a quick example.

    Remember that for an animation to be active it has to be currently playing or preloaded.

    * edit: I see Alex beat me to the punch! wink

    Imperator

    7285 Posts