User Tools

Site Tools


hpl2:tutorials:level_editor:dynamic_curtains

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl2:tutorials:level_editor:dynamic_curtains [2014/02/23 09:58]
amn
hpl2:tutorials:level_editor:dynamic_curtains [2014/02/23 11:19] (current)
amn
Line 1: Line 1:
 ==== Dynamic Curtains ==== ==== Dynamic Curtains ====
- 
-in progress 
  
 ==== Summary ==== ==== Summary ====
Line 7: Line 5:
 We can simulate the action of wind over curtains by using the plastic curtain from AMFP and the force function. We can simulate the action of wind over curtains by using the plastic curtain from AMFP and the force function.
  
-1. Get the files [[http://​www.moddb.com/​mods/​the-raven|LINK]]\\+==== 1. Get the files ==== 
 + 
 +\\
 You need a modified version of the curtains that better respond to force.\\ You need a modified version of the curtains that better respond to force.\\
-You can create your own version or just use the ones I already did in my mod.+You can create your own version or just use the ones I already did in my mod. [[http://​www.moddb.com/​mods/​the-raven|LINK]]
  
-Note: If you want to create your own version, make sure its bodies respond properly to force\\ +//Note: If you want to create your own version, make sure its bodies respond properly to force\\ 
-and behave correctly when moving, no lag, no weird things. Also remove collision with player.+and behave correctly when moving, no lag, no weird things. Also remove collision with player.// \\ 
 +\\ 
 +The files for the curtains are inside **/​models/​curtains** 
 +==== 2. Place the curtains. ====
  
-2. Place the curtains.\\+\\
 Put the curtains wherever you want but not touching the wall or each other.\\ Put the curtains wherever you want but not touching the wall or each other.\\
-Then resize its width all you want, remember the model is initially thin.+Then resize its width all you want, remember the model is initially thin.\\ 
 +//Note: **Curtains_Dynamic_001.ent** is transparent,​ the 002 is normal and the rest 003 and 004 are experimental copies, ignore those. // 
 +==== 3. Write the code. ====
  
-3. Write the code.\\ +The code below starts ​loop function ​that randomly pushes ​the curtains ​and plays the wind sound.
-You wanna start timer in your code that moves the curtains ​when the wind blows.+
  
-Add this line to your script fileinside your OnStart() ​function, it starts the wind function:+Open your script file and add the following line inside your OnStart() function:
  
 <code php> <code php>
-void OnStart ​() { +WindLoop ( ""​ ); 
-            ​WindLoop ​( ""​ );+</​code>​ 
 + 
 +Now copy&​paste this other function and it's ready. 
 + 
 +<code php> 
 +void WindLoop  ​string &in rabbit ​) 
 +
 +        ​AddPropImpulse  ​( "Curtain_1", ​  ​2, ​  ​0.5, ​  0, "​Local"​ ); 
 +        PlaySoundAtEntity ( "",​ "​TR_spooky_wind_whirl.snt",​ "​Curtain_1",​ 0, false ); 
 +        AddTimer ( "",​ RandFloat (3,5), "​WindLoop" );
 } }
 </​code>​ </​code>​
 +
 +//​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.\\
 +Don't forget to change the name of the curtain. \\
 +You can also change any given value -like the force- to get better results.//
 +
 +==== Extra Info ====
 +
 +- The sound **TR_spooky_wind_whirl.snt ** is the wind sound I used, you can use another one, remember to change the name in the function.\\
 +- "​Curtain_1"​ is the name of my curtain, yours may be different.\\
 +- The original code in my mod is a little more complex, you may want to take a look.
 +
 +Amn.-
  
hpl2/tutorials/level_editor/dynamic_curtains.1393149522.txt.gz · Last modified: 2014/02/23 09:58 by amn