Page 1 of 1
Vehicle animation
Posted: 01 Jun 2016 17:46
by oftcrash
Hi there!
I'm trying to figure out how to get an animation working on a vehicle using NML. I have 4 spritesets - 1 for each of the animation frames. As I understand it, I should use the motion_counter variable. Assuming I call this in a switch, what would that look like? Here's what I have right now (which is obviously incorrect).
Code: Select all
switch (FEAT_AIRCRAFT, SELF, sw_v22_hor_anim, (motion_counter / 256)) {
1: ss_ac_v22_hor_1;
2: ss_ac_v22_hor_2;
3: ss_ac_v22_hor_3;
4: ss_ac_v22_hor_4;
5: ss_ac_v22_hor_1;
6: ss_ac_v22_hor_2;
7: ss_ac_v22_hor_3;
8: ss_ac_v22_hor_4;
9: ss_ac_v22_hor_1;
10: ss_ac_v22_hor_2;
11: ss_ac_v22_hor_3;
12: ss_ac_v22_hor_4;
13: ss_ac_v22_hor_1;
14: ss_ac_v22_hor_2;
15: ss_ac_v22_hor_3;
16: ss_ac_v22_hor_1;
ss_ac_v22_hor_1;
}
Thanks!
Re: Vehicle animation
Posted: 01 Jun 2016 18:57
by Leanden
Is this for helicopters by chance?
Re: Vehicle animation
Posted: 01 Jun 2016 19:14
by oftcrash
Leanden wrote:Is this for helicopters by chance?
Sort of - its for a tiltrotor. I know there's support for rotors in helicopters, though I've only played with them a little bit. In this case though, I want it to both spin in the vertical as well as the horizontal position.
Re: Vehicle animation
Posted: 01 Jun 2016 21:35
by Leanden
I dont think that is possible. There are 4 sprites available for animated aircraft, 3 in motion on a cycle and fourth for landed position.
Re: Vehicle animation
Posted: 01 Jun 2016 21:57
by oftcrash
Is the only animation available for an aircraft the rotor, or can it be done through cycling through a few sprites for the vehicle. The docs for
motion_counter imply that it can be done, but I don't know what restrictions there might be on its usage.
Re: Vehicle animation
Posted: 01 Jun 2016 23:08
by Leanden
oftcrash wrote:Is the only animation available for an aircraft the rotor, or can it be done through cycling through a few sprites for the vehicle. The docs for
motion_counter imply that it can be done, but I don't know what restrictions there might be on its usage.
I suppose in theory you could do it that way. How would you tell the vehicle which way to point the rotors?
Re: Vehicle animation
Posted: 01 Jun 2016 23:56
by oftcrash
I have that part working in a separate switch.
Code: Select all
switch (FEAT_AIRCRAFT, SELF, sw_ac_v22, (var[0xE2, 0, 0xFF])) {
16: sw_v22_hor_anim; // final approach before landing or going for another round
18: sw_v22_hor_anim; // heading for tower contact point (where airplanes initiate their approach)
20: sw_v22_hor_anim; // heading for the final approach entry point
23: ss_ac_v22_ver; // helicopter taking off from airport
24: sw_v22_hor_anim; // helicopter preparing to land at airport
25: ss_ac_v22_ver; // helicopter landing at airport
26: ss_ac_v22_ver; // helicopter taking off from heliport
27: sw_v22_hor_anim; // helicopter preparing to land at heliport
28: ss_ac_v22_ver; // helicopter landing at heliport
ss_ac_v22_ver; // default
}
In flight it calls the animation switch (which doesn't animate at the moment, but does return the correct failover spriteset). When the state is landing or take-off, it switches over to the vertical animation switch.
Re: Vehicle animation
Posted: 02 Jun 2016 02:50
by Eddi
usually you would use the lowest bits of the motion counter, not the highest. so something like "motion_counter % 16" instead of "motion_counter / 256" (this would result in values 0 to 15). an alternative way to write this is "motion_counter & 0x0F"
Re: Vehicle animation
Posted: 02 Jun 2016 12:01
by oftcrash
Eddi wrote:usually you would use the lowest bits of the motion counter, not the highest. so something like "motion_counter % 16" instead of "motion_counter / 256" (this would result in values 0 to 15). an alternative way to write this is "motion_counter & 0x0F"
That did it. Thanks!