Animation per Knopfdruck abspielen

  • Hey Leute,


    ich schreibe mir gerade ein Script um per lua eine Animation abzuspielen, soweit so gut, aber ich will mal fragen ob das auch passt...


    [lua]AnimatedPart = {};


    function AnimatedPart.prerequisitesPresent(specializations)
    return true;
    end;


    function AnimatedPart:load(xmlFile)
    self.Animation = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.AnimPart#index"));

    self.AnimatedPartState = false;
    end;
    function AnimatedPart:delete()
    end;
    function AnimatedPart:mouseEvent(posX, posY, isDown, isUp, button)
    end;
    function AnimatedPart:keyEvent(unicode, sym, modifier, isDown)
    end;
    function AnimatedPart:update(dt)
    if self:getIsActiveForInput() then
    if InputBinding.hasEvent(InputBinding.Hub) then
    self.animationName = "hydraulika_opuszczanie";
    self:playAnimation(self.animationName, 1, nil, true)
    end;
    end;
    end;
    function AnimatedPart:updateTick(dt)
    end;
    function AnimatedPart:draw()
    end;
    [/lua]


    MfG

  • Ja, generell würde deine Animation funktionieren teilweise , sofern du sie auch in der XML definiert hast.


    Die "1" in [self:playAnimation(self.animationName, 1, nil, true)] ist die Richtung in der die Animation abgespielt wird. Ist dieser Wert fest, wird die Animation nur vorwärts abgespielt. Da ich davon ausgehe, dass du sie auch rückwärts abspielen möchtest, muss dieser Wert ebenfalls in einer Variable festgehalten werden, die ihren Wert mit dem Tastendruck von 1 auf -1 bzw von -1 auf 1 ändert ;)


    Mit dieser Korrektur sollte das Ganze funktionieren :)


    [expander]
    Function ..:Load :
    [lua]
    -- Wofür benötigst du einen Index? - Löschen
    self.Animation = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.AnimPart#index"));


    -- Auch hier stimmt etwas nicht...
    self.AnimatedPartState = false;
    -- ändern in :
    self.currentAnimationDirection = -1;
    [/lua]


    Function ..:Update :
    [lua]
    if self:getIsActiveForInput() then
    if InputBinding.hasEvent(InputBinding.Hub) then
    -- -1*-1 = 1 | 1*-1 = -1
    self.currentAnimationDirection = self.currentAnimationDirection*-1; -- Wert 1[Animation vorwärts] oder Wert -1[Animation rückwerts]
    self:playAnimation("hydraulika_opuszczanie", self.currentAnimationDirection , nil, true)
    end;
    end;
    [/lua][/expander]



    MfG

  • Nicht, dass ich dir gleich was unterstellen möchte, aber warum steht da polnischer Text in deinem Script? Passt nicht so ganz zu deinem "i bin a Alleskönner" :D


    Nuja, tut mir Leid für Offtopic, den wirklich hilfreichen Part hat ja Fiat 80-90 DT schon geschrieben.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!