Nic 0 Posted May 11, 2003 I have a boat with a prop...and i was hoping to have it spin the way props spin on a heli. At the moment I just have it set as a "radar" so it spins...but just not the way id really like it to. I ve heard of using eventhandler "engine" somehow, to trigger it to start when the engine starts...but im not sure exactly how it works. Could someone explain this to me? Or give an example code? Â That would be sweet...and thanks in advance! Share this post Link to post Share on other sites
Jimboh 0 Posted June 23, 2003 well, to use them, first you need to add this bit of code within the class of your boat: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class eventhandlers { engine="[_this select 0] exec ""\youraddonfolder\propeller.sqs"";" }; Then you need to edit your model: - select your propeller and make a new selection called "propeller" - go into memory, and create two vertices for its axis and create a selection called "prop_axis" (for more info on this go to HERE) - save and close Oxygen then go back to your config.cpp and add this bit of code above the eventhandler: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class Animations { class propeller { type="rotation"; animPeriod=1; selection="propeller"; axis ="prop_axis"; angle0=0; angle1=300000; }; }; youre done with the config file. - now, in the same folder as your addon, create a (text) file called propeller.sqs - then copy and paste this code into the file: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Based off [SZ]Vladimir's dragonwarrior rotor animation script _boat1 = this select 0 #main If ( not alive _boat1 ) then {exit} @(isengineon _boat1) #loop If ( (_boat1 animationPhase "propeller") == 0) then {_boat1 animate["propeller",1]} If ( (_boat1 animationPhase "propeller") == 1) then {_boat1 animate["propeller",0]} ~0.001 If ( (alive _boat1) && (isengineon _boat1) ) then {goto "loop"} goto "main" save and compile your addon, and your propeller should work If I'm missing anything, please correct me Share this post Link to post Share on other sites
BraTTy 0 Posted June 24, 2003 Just that I don't see how that will do continuious animations (spinning) Share this post Link to post Share on other sites
Bullz_eye_on_my_back 0 Posted June 24, 2003 I there with ya bratty, it doesn't seem like it would do the continous animation, but I've seen the dragon warrior do it... not sure how it works... one question though.. the script is called everytime the engine is turned on... so couldn't you just exit the script instead of going back to the "main" loop that way the @(isengine on) is not causing your cpu to check every 0.5 seconds for if the engine is on Share this post Link to post Share on other sites
BraTTy 0 Posted June 24, 2003 Right...seeing the 1 second animation period defined in the animation,it would be a slow animation if it worked But calling it every .001 and keep switching from 1 to 0 like that isnt gonna rotate it.Its not gonna work in that example Look at the Pak36 towable artillery to see how I did continous animation.Similiar way also in use on the wheels of my plane thats not released yet. You need a fast animation period: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class Animations { class propeller { type="rotation"; animPeriod=.0001; selection="propeller"; axis ="prop_axis"; angle0=0; angle1=300000; }; }; And then increment it little by little: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; Based off BraTTy's Pak towing script _boat = this select 0 #cycle ~.001 _aphase = _aphase + .02 _boat animate ["propeller", _aphase] ? _aphase >= 1 : _aphase = 0 ? ! isengineon _boat: exit goto "cycle" You can even get fancy and make a formula to make it spin faster depending on speed,but that wouldn't be necessary for a prop Share this post Link to post Share on other sites
Jimboh 0 Posted June 24, 2003 angle is 300000, so that means it rotates 300000 radians per second. The script checks if the rotation is complete, then if it is, it rotates it again. BTW, has anyone actually tried out this script? Because I haven't, but I'm just curious Share this post Link to post Share on other sites
BraTTy 0 Posted June 25, 2003 Ahh I see ...and oops I also left that 300000 animation radius Should be angle1=-6.2831853072; And no I havent tried that addon, been too busy with my own stuff Share this post Link to post Share on other sites
Jimboh 0 Posted June 25, 2003 Oops, my explanation is a bit flawed... Once the rotation is completed, it rotates backwards, then once thats complete, it rotates forewards again (it goes so fast you can't tell the difference), and goes on and on... Share this post Link to post Share on other sites
Nic 0 Posted June 25, 2003 hehe - whoa sweet - i totally forgot about this thread haha Thanks for the help you guys!! Ive since updated it to use animation to spin..but the way I was doing it wasnt that great. Ill try this way out as soon as i get a chance! Â Thanks again Share this post Link to post Share on other sites