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:script:force
<h1>Force and impulses</h1> <div class="level1"> <p> In this tutorial I (xtron) will explain how to use Prop/Body force and impulses </p> <p> <b>How to get the coordinates:</b> </p> <p> Create an item were the player/prop stands when it/he's geting pushed then you press ctrl+d ( duplciate it ) and drag it to the place where </p> <p> he's going to get pushed to. </p> <p> <a href="http://imageshack.us/f/706/positiong.png/" class="urlextern" title="http://imageshack.us/f/706/positiong.png/" rel="nofollow">imageshack.us/f/706/positiong.png/</a> </p> <p> Lets say that blue dot is the player/prop and he's going to get pushed to the chair that got the X position -3.5, you replace "float afX" </p> <p> with "-3.5f" and you're done. </p> <p> And there you go, you just found out how to get the coordinates. </p> </div> <h2>force/impulse:</h2> <div class="level2"> <p> I will use BodyForce for an example only, you can use PropForce exactly the same as BodyForce. </p> <pre class="code c++">AddBodyForce<span class="br0">(</span>string<span class="sy0">&</span> asName<span class="sy0">,</span> <span class="kw4">float</span> afX<span class="sy0">,</span> <span class="kw4">float</span> afY<span class="sy0">,</span> <span class="kw4">float</span> afZ<span class="sy0">,</span> string<span class="sy0">&</span> asCoordSystem<span class="br0">)</span><span class="sy0">;</span> </pre><p> </p> <p> This function will push the player in a certain direction and by using the method I showed you, you will get the coordinates. </p> <p> We will use the same coordinates shown on the picture. </p> <p> <a href="http://imageshack.us/f/706/positiong.png/" class="urlextern" title="http://imageshack.us/f/706/positiong.png/" rel="nofollow">imageshack.us/f/706/positiong.png/</a> </p> <p> Lets say the player stands on the blue dot and is geting to the chair. you will need to modify the function like this: </p> <pre class="code c++">AddBodyForce<span class="br0">(</span>"Player"<span class="sy0">,</span> <span class="sy0">-</span><span class="nu17">3.5f</span><span class="sy0">,</span> <span class="nu17">0.0f</span><span class="sy0">,</span> <span class="nu17">0.0f</span><span class="sy0">,</span> "world"<span class="br0">)</span><span class="sy0">;</span> </pre><p> </p> <p> the player will now be pushed to the X coordinate -3.5. He will NOT move in the air unless you change the Y coordinate a bit. </p> <p> If you move the chair upp a bit you will see that the Y coordinate will change. When you're done you need to change the code again </p> <p> like this: </p> <p> Lets say you moved the chair so Y is 2.0 </p> <pre class="code c++">AddBodyForce<span class="br0">(</span>"Player"<span class="sy0">,</span> <span class="sy0">-</span><span class="nu17">3.5f</span><span class="sy0">,</span> <span class="nu17">2.0f</span><span class="sy0">,</span> <span class="nu17">0.0f</span><span class="sy0">,</span> "world"<span class="br0">)</span><span class="sy0">;</span> </pre><p> </p> <p> Now will the player fly abit aswell. </p> <p> <b>THIS CAN BE USED WITH</b> </p> <pre class="code c++">AddPropForce<span class="br0">(</span>string<span class="sy0">&</span> asName<span class="sy0">,</span> <span class="kw4">float</span> afX<span class="sy0">,</span> <span class="kw4">float</span> afY<span class="sy0">,</span> <span class="kw4">float</span> afZ<span class="sy0">,</span> string<span class="sy0">&</span> asCoordSystem<span class="br0">)</span><span class="sy0">;</span> </pre><p> </p> <p> <b>Aswell!</b> </p> <p> <b>READ!:</b> IF YOU'RE GONNA USE AN IMPULSE I SUGGEST YOU USE HIGH NUMBERS LIKE "500.0f" OR "5000.0f" </p> <p> <em><u>Created by xtron</u> </em> </p> </div>
hpl2/tutorials/script/force.txt
· Last modified: 2012/06/06 12:20 by
theforgot3n1
Page Tools
Show page
Old revisions
Backlinks
Export to PDF
Back to top