Jump to content

Animations killing frame rate


Recommended Posts

I have made a series of parts, a couple different intakes and an engine. All of them have an animation that is controlled by throttle. They were made in Blender and directly imported into unity as .blend files. Under the Inspector/Rig I set the animation type to legacy and can then access the 'Default Take' for use in game.

I am using either

MODULE

{

name = FXModuleAnimateThrottle

animationName = Default Take

dependOnEngineState = True

responseSpeed = 0.1

}

or

MODULE

{

name = FXModuleAnimateThrottle

animationName = Default Take

dependOnEngineState = True

}

in the part.cfg.

With all of that explained: Having more than say 4-6 of these parts does bad things to my frame rate. Any ideas?

Link to comment
Share on other sites

Well the general idea is that your entire animation in blender gets chopped up in unity allowing for multiple animations to be taken from the one blender file. Like animation 1 may use frames 0-200 where something jumps in the air and animation 2 uses frames 201-400.

But addressing colliders, a simpler collider or less tri's of your model tend to help with framerate. (I know that complex looking models with even simple colliders get lagged to crap when hit by lights)

If you want you can put the part in drop box and Ill try it out and see if I get the same framedrops or something.

Link to comment
Share on other sites

Having more than say 4-6 of these parts does bad things to my frame rate. Any ideas?

Does any of your parts have more then one animation? If that's the case, you can split the animation files into two (technically). If not, then that's a mystery. How many frames are you using for the animations? Not that I've had much experience with the vanilla animation module, but it has acted wonky on me before, and neither Kreuzung's or JDP's animation plugins have given me that kind of trouble.

Normally I just create a new animation clip in Unity and then attach it to the parent object of the group that I'm animating. Although a simple singular animation I'll just do in Blender.

Link to comment
Share on other sites

I have experimented alot, and it seems that if I make any animations more than 120 frames, I get the same lag as you Sasquatch, the best I could do was lower the frames used and make the animation play slower.

Link to comment
Share on other sites

I have experimented alot, and it seems that if I make any animations more than 120 frames, I get the same lag as you Sasquatch, the best I could do was lower the frames used and make the animation play slower.

Must be colliders... I have an animation with 1200 frames, I see no impact at all on performance. I even animated 7 separate 1200 frame animations at once.

Link to comment
Share on other sites

I'll limit some of the colliders and see if that helps. These are only 60 frame animations, since they are linked to throttle. I wondered if it was because of the throttle connection that it was hitting this hard

Link to comment
Share on other sites

So, i simplified the colliders by about 50% and it had no effect at all. I turned off the animations and gained 36 fps which I'm sure would be more but my vsync is set to 60hz

Colliders don't make any difference to the animation speed, not for me anyway. As I said, the only way to reduce the lag I found was to simply remove the amount of frames I am using.

Take a look at the stock solar panel for example..

Count in seconds how long it takes to unfold, 2 seconds maybe? 2.5 seconds?

1 second = 30 frames of animation (default) so really, the solar panel should be between 60-90 frames maybe?

Now one of them doesn't lag, but you put 6 on your ship and deploy them all at once, and walla, lag.

Link to comment
Share on other sites

unfortunately the throttle animations are all set to 60 frames, 1 frame per position so that they move in concert with throttle position. I think I will try animating them directly in unity instead of importing a blender animation.

InfiniteDice, what do you use for your animations?

I stil lthink it may be tied into the throttle link.. effectively the animation is constantly playing and the position be recalculated

Edited by SasquatchM
Link to comment
Share on other sites

unfortunately the throttle animations are all set to 60 frames, 1 frame per position so that they move in concert with throttle position. I think I will try animating them directly in unity instead of importing a blender animation.

InfiniteDice, what do you use for your animations?

I stil lthink it may be tied into the throttle link.. effectively the animation is constantly playing and the position be recalculated

I use moduleAnimateGeneric that I drive through my own code as far as I can recall, when I'm home from work I'll check in detail. Like I said I have tripped 7 1200 frame duration animated parts at the same time 0 lag. Keep in mind my part has two colliders each with 6 faces, and the total part poly count is under 300.

Now if you have any code checking the position of that animation, and it needs to talk back and forth with other code... it could cause lag. Straight up animation shouldn't. All it is is simple transform position data.

Multiplayer games running at 30ms lag are transmitting way more than a simple transform position in 30 thousandths of a second. Not that that really has anything to do with this. But animation run times shouldn't cause lag.

Some other thoughts...

If your animation is playing with anything physics it could cause lag, like altering COG or thrust position... I never thought of mentioning that before, also anything with lights or other fx...

Edited by InfiniteDice
Link to comment
Share on other sites

Basically the position of the throttle determines the position in the animation 50% throttle will set the animation to frame 30 out of the 60 frame animation. Basically I am using the throttle animation method from the ion engines but having the animation control rotation of a part through the animation instead of an emissive

Link to comment
Share on other sites

Basically the position of the throttle determines the position in the animation 50% throttle will set the animation to frame 30 out of the 60 frame animation. Basically I am using the throttle animation method from the ion engines but having the animation control rotation of a part through the animation instead of an emissive

mmm...

You might want to limit how many times it is trying to update this. It should be possible if you timed the refresh down a bit. So every second, update the position of the animation rather than 30+ times per second or whatever the frame rate is running at.

This would require a bit of code to function properly.

Link to comment
Share on other sites

AFAIK unchecking "animate physics" helps a lot on framerates when you're animating objects with colliders.

It might not be that big of a lag factor any more though, since the bug of the debug spamming "resetting inertial tensors" while animating colliders was removed somewhere between 0.18 and 0.19

Link to comment
Share on other sites

I had this issue with my space capsule im working on. Found out that it was trying to animate to many parts at once. I had a hatch door with all separate parts on it like handles moving and gears and it became to complex for ksp and ended up just lagging.

Moral of the stories is to combine parts so its just one solid part moving and not a parent with a bunch of children following it. If you need a picture for better explanation i will do so. Just fix your hierarchy.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

×
×
  • Create New...