Jump to content

How to ensure ..


Alienhead
 Share

Go to solution Solved by Josh,

Recommended Posts

An animation plays from the starting frame ?  For example - I call this 

player.entity:PlayAnimation("opendoor", .1, 250, 1)
 

 

Notice this is a single one shot animation, no looping. 

But sometimes it starts at the end, at the middle, at the beginning, sometimes never see any animation at all.  I've experienced this since I first started working with LE. never brought it up as it wasn't that important then, but now its is. 

 

Link to comment
Share on other sites

  • Alienhead changed the title to How to ensure ..

Oddly, after loading the same model but using asset_unmanaged - it won't play the animation at all.  This is strange, as I usually always get it to play the animation at some point in the time line. Are the animation shaders tied to each other? Like if I have 10 of the same models loaded and each model is playing a different sequence will that effect each other?  I've not really ran across this problem in LE before, its got me puzzled.  Just to be clear, I've tried many different models so it's not the mesh itself. 

The pic below, shows left mob animated in idle, the right side mob is animated in a non- loop sequence but it won't play.  Every once in awhile I'll get one of the other mobs to play some random location in the sequence.  Ignore the girl in t-pose, I haven't got her turned on in this part.

prob.thumb.jpg.3097b44e20d92bc26b6213bfccc1e43e.jpg

Link to comment
Share on other sites

  • Solution

I think the one-shot animation issue is something I only discovered in the Ultra code that carried over from Leadwerks. The best thing to do here is control the animation frame by setting it in each Update call. You can set the exact frame time of an animation with Entity::SetAnimationFrame

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Actually, you can use Script:Draw if you keep track of the timing. Then the animation only gets updated when the entity is drawn.

Ultra is so much simpler in some aspects, it just has Update().

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

12 minutes ago, Josh said:

Actually, you can use Script:Draw if you keep track of the timing. Then the animation only gets updated when the entity is drawn.

Ultra is so much simpler in some aspects, it just has Update().

Yes!  And one day I'll be enjoying what is UltraEngine... just not this day. :( 

Link to comment
Share on other sites

One last question please..

Do I need to frame tween this animation sequence or is the draw command called as the physics block is?

function Script:Draw()
   
 
    if self.anim == "atk_hard" then  -- add more
 
        if player.tmr_frameplay < Time:Millisecs() then
 
            self.entity:SetAnimationFrame(player.atframe, 1.0, self.anim, true)
 
            player.atframe = player.atframe + 1
            player.tmr_frameplay = Time:Millisecs() + 15
 
            local frm = self.entity:GetAnimationLength("atk_hard")
            if player.atframe + 1 > frm then
                self.newanim = "swordidle"
                self.animspeed = oa_idlespeed
                self.animloop = 0
                self.animtrans = 300
                turnoveranim = true
                player.atframe=0
            end
        end
 
    end
 
end

Or : ( with frame tween ) 

function Script:Draw()
       if self.anim == "atk_hard" then  -- add more
 
        if player.tmr_frameplay < Time:Millisecs() then
 
            self.entity:SetAnimationFrame(player.atframe, 1.0, self.anim, true)
 
            player.atframe = player.atframe + 1
            player.tmr_frameplay = Time:Millisecs() + 15 *Time:GetSpeed()
 
            local frm = self.entity:GetAnimationLength("atk_hard")
            if player.atframe + 1 > frm then
                self.newanim = "swordidle"
                self.animspeed = oa_idlespeed
                self.animloop = 0
                self.animtrans = 300
                turnoveranim = true
                player.atframe=0
            end
        end
    end
end
 

 

Link to comment
Share on other sites

Since you are adding a fixed amount to the current frame each time, I think you will need to multiply that by the speed to handle differing framerates.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Ahh I see what your talking about now.. this is much much smoother and easier to control the speed of the animation.  Thanks again.

 

 

 
function Script:Draw()
    
    if self.anim == "atk_hard" then  -- add more
 
        player.atframe = player.atframe + .1 *Time:GetSpeed()
        self.entity:SetAnimationFrame(player.atframe, 1, self.anim, true)
 
        if player.atframe > self.entity:GetAnimationLength("atk_hard"then  -- end the one-shot
            turnoveranim = true
        end
 
     end
end
  

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...