skip to content
Frictional Game Wiki
User Tools
Register
Log In
Site Tools
Search
Tools
Show page
Old revisions
Backlinks
Recent Changes
Media Manager
Sitemap
Log In
Register
>
Recent Changes
Media Manager
Sitemap
Trace:
hpl2:tutorials:level_editor:dynamic_curtains
<h3>Dynamic Curtains</h3> <div class="level3"> </div> <h3>Summary</h3> <div class="level3"> <p> We can simulate the action of wind over curtains by using the plastic curtain from AMFP and the force function. </p> </div> <h3>1. Get the files</h3> <div class="level3"> <p> <br/> You need a modified version of the curtains that better respond to force.<br/> You can create your own version or just use the ones I already did in my mod. <a href="http://www.moddb.com/mods/the-raven" class="urlextern" title="http://www.moddb.com/mods/the-raven" rel="nofollow">LINK</a> </p> <p> <em>Note: If you want to create your own version, make sure its bodies respond properly to force<br/> and behave correctly when moving, no lag, no weird things. Also remove collision with player.</em> <br/> <br/> The files for the curtains are inside <b>/models/curtains</b> </p> </div> <h3>2. Place the curtains.</h3> <div class="level3"> <p> <br/> Put the curtains wherever you want but not touching the wall or each other.<br/> Then resize its width all you want, remember the model is initially thin.<br/> <em>Note: <b>Curtains_Dynamic_001.ent</b> is transparent, the 002 is normal and the rest 003 and 004 are experimental copies, ignore those. </em> </p> </div> <h3>3. Write the code.</h3> <div class="level3"> <p> The code below starts a loop function that randomly pushes the curtains and plays the wind sound. </p> <p> Open your script file and add the following line inside your OnStart() function: </p> <pre class="code php">WindLoop <span class="br0">(</span> "" <span class="br0">)</span><span class="sy0">;</span> </pre><p> </p> <p> Now copy&paste this other function and it's ready. </p> <pre class="code php">void WindLoop <span class="br0">(</span> string <span class="sy0">&</span>in rabbit <span class="br0">)</span> <span class="br0">{</span> AddPropImpulse <span class="br0">(</span> "Curtain_1"<span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu19">0.5</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> "Local" <span class="br0">)</span><span class="sy0">;</span> PlaySoundAtEntity <span class="br0">(</span> ""<span class="sy0">,</span> "TR_spooky_wind_whirl<span class="sy0">.</span>snt"<span class="sy0">,</span> "Curtain_1"<span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="kw4">false</span> <span class="br0">)</span><span class="sy0">;</span> AddTimer <span class="br0">(</span> ""<span class="sy0">,</span> RandFloat <span class="br0">(</span><span class="nu0">3</span><span class="sy0">,</span><span class="nu0">5</span><span class="br0">)</span><span class="sy0">,</span> "WindLoop" <span class="br0">)</span><span class="sy0">;</span> <span class="br0">}</span> </pre><p> </p> <p> <em>That's the most basic way to do it using only one curtain, from here you can add all the curtains you want by copy&pasting the PropImpulse and PlaySound lines.<br/> Don't forget to change the name of the curtain. <br/> You can also change any given value -like the force- to get better results.</em> </p> </div> <h3>Extra Info</h3> <div class="level3"> <p> - The sound <b>TR_spooky_wind_whirl.snt </b> is the wind sound I used, you can use another one, remember to change the name in the function.<br/> - "Curtain_1" is the name of my curtain, yours may be different.<br/> - The original code in my mod is a little more complex, you may want to take a look. </p> <p> Amn.- </p> </div>
hpl2/tutorials/level_editor/dynamic_curtains.txt
· Last modified: 2014/02/23 11:19 by
amn
Page Tools
Show page
Old revisions
Backlinks
Export to PDF
Back to top