Jump to content
Sign in to follow this  
colonel_klink

Continuous animations - a mini tutorial

Recommended Posts

Now I searched both here and at the OFPEC Forums and couldn't find any thing to create a continuous animation for the radar on the blockhouse that i am currently refurbishing while recovering from a sickness (just attacking the simpler addons these days smile_o.gif )

Anyway here goes:

If people can remember the old radar station I made eons ago.. which was an ambitious project using tank classes to get the animated radar antenna and screen to work.. Once 1.91 came out I have been asked if I was going to update the addon. Well I thought I might, and also make the addon more user friendly in both editor and in map making. The animation is made continuous using the following code:

In your config.cpp Class Animations:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class Radar

{

type="rotation";

animPeriod=0.01;

selection="radar";

axis="osaradar";

angle0=0;

angle1 = 6.283161;

};

The addon init eventhandler:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = [_this select 0] exec "\addonname\radar.sqs";

And the animation code in radar.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_radar1= _this select 0

#Reset

_PosRadar =0

_radar1 animate ["radar", 0]

?(not alive _radar1):goto "exit"

#loop

~0.01

_posradar= _posradar + 0.010

_radar1 animate ["radar",_PosRadar]

?(_posradar<=0.99): goto "loop"

goto "reset"

#Exit

exit

The above gives a nice steady rotation which doesn't reverse rotate, and continues until the radar is dead.

And a piccy:

radar2.jpg

Share this post


Link to post
Share on other sites
Guest

And we can download it from....? smile_o.gif

Share this post


Link to post
Share on other sites

Nice! If I update the dune buggy I'll try to animate the fan of the engine like this.

PSC blues.gif

Share this post


Link to post
Share on other sites
Guest

Wooot! Ta Red, and thx Col smile_o.gif

Share this post


Link to post
Share on other sites

This method has a ton of uses!!! If you ever have a car or vehicle with more wheels than allowed you could make them all move this way! Even set them up for the spinning to corrolate with the speed!! Samething with propellers and ...whew what ever needs to spin wooo hooo!! I can't wait untill everyone utilizes animations in all the new addons coming out

wtg Colonel

Share this post


Link to post
Share on other sites

The towable Pak that I helped Vibes with has continous animation on the wheels and I stated that when it came out.

The model is unbinarized

WW2 Corsair F4U also has continous animated wheels

Share this post


Link to post
Share on other sites
The towable Pak that I helped Vibes with has continous animation on the wheels and I stated that when it came out.

The model is unbinarized

WW2 Corsair F4U also has continous animated wheels

Bratty. Do you want to add the code here. I've been scratching my head how to get the speed to work with the animations.

Cheers

Klinkster

Share this post


Link to post
Share on other sites

Similar (but IMHO better a little) method was featured in this tutorial:

http://ofp.gamezone.cz/_hosted/brsseb/tutorials/lesson9/lesson9_a.htm

Yet another method is to define building as tank and use 'radar' gauge for such continuous rotation...

Anyways, both methods are AFAIK useles when you want to use such building from the WRPEdit - animation will start only if triggered by user's action (when first method is used), there is no way to perform animation via event handler etc sad_o.gif

Share this post


Link to post
Share on other sites
Similar (but IMHO better a little) method was featured in this tutorial:

http://ofp.gamezone.cz/_hosted/brsseb/tutorials/lesson9/lesson9_a.htm

Yet another method is to define building as tank and use 'radar' gauge for such continuous rotation...

Anyways, both methods are AFAIK useles when you want to use such building from the WRPEdit - animation will start only if triggered by user's action (when first method is used), there is no way to perform animation via event handler etc sad_o.gif

The original radar I made used several models in one addon which included 2 tanks. This made the addon clumsy in the editor. Then I used a different method similar to Brssebs but I still wanted a constant animation that would loop, hence the explanation above.

The addons can be placed on a map and animated, however the downside (at the moment) is that the script must be placed in the mission and called from with in the mission. Hopefully there will be a way around this by getting animations to work from within the Island config.

I have tried calling the animation script from an island config but until now no luck.. Back to the drawing board i guess.

Share this post


Link to post
Share on other sites
The towable Pak that I helped Vibes with has continous animation on the wheels and I stated that when it came out.

The model is unbinarized

WW2 Corsair F4U also has continous animated wheels

Bratty. Do you want to add the code here. I've been scratching my head how to get the speed to work with the animations.

Cheers

Klinkster

Sure ..here's from the Corsair's wheels.sqs

#cycle

_aphase = _aphase + ((speed _plane) /350)

_plane animate ["corwheels", _aphase]

? _aphase >= 1 : _aphase = 0

~.01

goto "cycle"

I took out some irrelevant stuff

The towable Pak uses the same method to continous animate the wheels depending on the vehicles speed using this line:

_aphase + ((speed _plane) /350)

You may want to change the ratio some depending on the speed of the vehicle (a vehicle faster than 350kph will want a higher ratio)

_aphase + ((speed _plane) /450)

So that the figure never results in a "1" or higher than a "1"

The towable Pak is unbinarized ,the Corsair is binarized for size ,the unbinarized files are available , just I don't have a host

Both addons have continous variable animated wheels

Another thing to remember is that animations are global and won't need to be called from each machine in a mp game, unfortunately the method that is used on the planes have some hidden selections and thats another story, as the fake unretracting wheels needs some texture juggling

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×