Separate animation for helicopter blades

Place to get help with not working mods / modding interface.
Post Reply
User avatar
kumpu
Fast Inserter
Fast Inserter
Posts: 111
Joined: Wed Jun 07, 2017 10:10 am
Contact:

Separate animation for helicopter blades

Post 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

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Separate animation for helicopter blades

Post by darkfrei »

The rotor is another car!

User avatar
kumpu
Fast Inserter
Fast Inserter
Posts: 111
Joined: Wed Jun 07, 2017 10:10 am
Contact:

Re: Separate animation for helicopter blades

Post 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.

User avatar
kumpu
Fast Inserter
Fast Inserter
Posts: 111
Joined: Wed Jun 07, 2017 10:10 am
Contact:

Re: Separate animation for helicopter blades

Post by kumpu »


Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: Separate animation for helicopter blades

Post 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.

User avatar
kumpu
Fast Inserter
Fast Inserter
Posts: 111
Joined: Wed Jun 07, 2017 10:10 am
Contact:

Re: Separate animation for helicopter blades

Post 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

Post Reply

Return to “Modding help”