Page 1 of 1

Separate animation for helicopter blades

Posted: Wed Jun 07, 2017 10:39 am
by kumpu
Hi, I'm currently creating a helicopter mod. I want this to look nice, so it should have a spinning rotor.
However it seems that animations in car entitys are hardcoded to the forward direction. I understand why that makes sense for cars but it really sucks for my purposes.
In general it seems that entity animations are tied directly to ingame behaviour, and I can't find a way to get script control over them. I mean not only has the rotor animation to be independent of the body animation/orientation, I also need to be able to stop it and set its speed...
So is there a way to do this?

To make this post more exciting, here is a screenshot of how it looks so far.

Image

Re: Separate animation for helicopter blades

Posted: Wed Jun 07, 2017 4:37 pm
by darkfrei
The rotor is another car!

Re: Separate animation for helicopter blades

Posted: Wed Jun 07, 2017 6:38 pm
by kumpu
Yeah, I found out about that trick by looking at this mod
viewtopic.php?f=14&t=12747

Gosh that sucks. I would have thought an excellent game like factorio would have an excellent modding system as well but eh.

Re: Separate animation for helicopter blades

Posted: Tue Jun 13, 2017 1:27 am
by kumpu

Re: Separate animation for helicopter blades

Posted: Tue Jun 13, 2017 2:10 am
by Supercheese
Whew, that's quite a lot of code shenanigans just to get a smartly animated rotor!
Seems you've made it work like you wanted, kudos.

Re: Separate animation for helicopter blades

Posted: Tue Jun 13, 2017 10:02 am
by kumpu
Thanks! Oh man, the entire code is a shenanigan. The rotor is another car but for some reason vehicle orientation does not directly translate to the displayed frame. Looks like they have some kind of easing applied, as you can see here in this image.
Image
(x axis is what frame should be displayed - meaning orientation = x/64, since I use 64 frames. The line in blue shows whats drawn instead).
So I had to translate those values and the entire process just sucked. I really hope they will improve their API.
Looks pretty funny on the map tho :D