| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
hpl2:tutorials:level_editor:dynamic_curtains [2014/02/23 09:19] amn |
hpl2:tutorials:level_editor:dynamic_curtains [2014/02/23 11:19] (current) amn |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== Dynamic Curtains ==== | ==== Dynamic Curtains ==== | ||
| - | on progress | + | ==== Summary ==== |
| + | |||
| + | We can simulate the action of wind over curtains by using the plastic curtain from AMFP and the force function. | ||
| + | |||
| + | ==== 1. Get the files ==== | ||
| + | |||
| + | \\ | ||
| + | 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. [[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\\ | ||
| + | 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. ==== | ||
| + | |||
| + | \\ | ||
| + | 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.\\ | ||
| + | //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. ==== | ||
| + | |||
| + | The code below starts a loop function that randomly pushes the curtains and plays the wind sound. | ||
| + | |||
| + | Open your script file and add the following line inside your OnStart() function: | ||
| + | |||
| + | <code php> | ||
| + | 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> | ||
| + | |||
| + | //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.- | ||