<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Arunning_up_walls</id>
	<title>Hpl2:Tutorials:script:running up walls - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Arunning_up_walls"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:running_up_walls&amp;action=history"/>
	<updated>2026-05-15T03:28:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:running_up_walls&amp;diff=858&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:running_up_walls&amp;diff=858&amp;oldid=prev"/>
		<updated>2020-07-09T13:48:51Z</updated>

		<summary type="html">&lt;p&gt;Upload from wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Running up walls =&lt;br /&gt;
&lt;br /&gt;
This code will simulate the player running up walls.&amp;lt;br /&amp;gt;Since code ends up being too large and thus confusing, i'm dividing it in parts.&lt;br /&gt;
&lt;br /&gt;
1. How it works&lt;br /&gt;
&lt;br /&gt;
[http://s21.postimg.org/cjfsgmqqv/running_up_walls_image_1.jpg?direct&amp;amp;]&lt;br /&gt;
&lt;br /&gt;
This feature uses areas to determine where the wall is and to detect when the player jumps to it.&amp;lt;br /&amp;gt;Using the function ''AddPlayerBodyForce'' i can simulate the force of each leg running up.&lt;br /&gt;
&lt;br /&gt;
To get the interval between steps, i'm using ''Timers''.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;We declare the area collision:  (''AreaWall1 '' is the area covering the wall and ''WallRunCollide '' is the function.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void OnStart {&lt;br /&gt;
	AddEntityCollideCallback( &amp;quot;Player&amp;quot;, &amp;quot;AreaWall1&amp;quot;, &amp;quot;WallRunCollide&amp;quot;, false, 1  );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is the function that triggers when the players collides with the area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void WallRunCollide ( string &amp;amp;in p, string &amp;amp;in c, int s ) {&lt;br /&gt;
	AddPlayerBodyForce( 0, 20000, 0, false );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Adjusting code +''Timer'' +''Loop''&lt;br /&gt;
&lt;br /&gt;
''BodyForce '' function uses large numbers, so i'm using a variable instead:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void WallRunCollide ( string &amp;amp;in p, string &amp;amp;in c, int s ) {&lt;br /&gt;
	float M = 10000;&lt;br /&gt;
	AddPlayerBodyForce( 0, 2*M, 0, false );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will push the player up just once, so i'm adding a ''Timer+Loop '' to repeat the impulse (5 times):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void WallRunCollide ( string &amp;amp;in p, string &amp;amp;in c, int s ) {&lt;br /&gt;
	float i = 0.25; int n = 5; float r = 0;&lt;br /&gt;
&lt;br /&gt;
	for ( int v = 1; v &amp;lt;= n; v++ ) {&lt;br /&gt;
		AddTimer ( &amp;quot;&amp;quot;, r, &amp;quot;RunOnMe&amp;quot; );&lt;br /&gt;
		r = r +i;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, the content changed, i moved it to another new function.&amp;lt;br /&amp;gt;I added 3 variables, interval, number and a counter.&amp;lt;br /&amp;gt;These are used in the ''for loop.&amp;lt;br /&amp;gt;'' This loop will set a ''Timer'' to call the function &amp;quot;''RunOnMe''&amp;quot; ''n'' times, on an interval of ''i '' seconds.''&amp;lt;br /&amp;gt;'' &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;Below is the new function i created that the ''Timers'' will trigger:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void RunOnMe ( string &amp;amp;in t ) {&lt;br /&gt;
	float M = 10000;&lt;br /&gt;
	AddPlayerBodyForce( 0, 2*M, 0, false );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is supposed to be a step, i'm adding a sound:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void RunOnMe ( string &amp;amp;in t ) {&lt;br /&gt;
	float M = 10000;&lt;br /&gt;
	AddPlayerBodyForce( 0, 2*M, 0, false );&lt;br /&gt;
	PlayGuiSound( &amp;quot;step_run_female_rock.snt&amp;quot;, 0.4 );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, the code is working fine. You can test it out.&lt;br /&gt;
&lt;br /&gt;
3. Preventions&lt;br /&gt;
&lt;br /&gt;
Now we have to consider possible bugs.&amp;lt;br /&amp;gt;We don't want to trigger this if the player didn't jump.&amp;lt;br /&amp;gt;It would look weird and just fail cause there's not enough starting force.&amp;lt;br /&amp;gt;We can avoid that using ''GetPlayerYSpeed()'' function, anything below 1 is not jumping:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void WallRunCollide ( string &amp;amp;in p, string &amp;amp;in c, int s ) {&lt;br /&gt;
&lt;br /&gt;
	if ( GetPlayerYSpeed() &amp;lt;1 ) { return; }&lt;br /&gt;
	float i = 0.25; int n = 5; float r = 0;&lt;br /&gt;
&lt;br /&gt;
	for ( int v = 1; v &amp;lt;= n; v++ ) {&lt;br /&gt;
		AddTimer ( &amp;quot;&amp;quot;, r, &amp;quot;RunOnMe&amp;quot; );&lt;br /&gt;
		r = r +i;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That new condition i just added will stop the code by using the ''return '' function.&amp;lt;br /&amp;gt;So player may walk into the wall area and not get thrown up by the wall running code.&lt;br /&gt;
&lt;br /&gt;
4. Direction&lt;br /&gt;
&lt;br /&gt;
We are adding now a small tweak to our code to let the player direct his wall running.&amp;lt;br /&amp;gt;Using ''AddPlayerBodyForce '' we can add a slight push ahead: ( just to help the player go where he's looking at)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
void RunOnMe ( string &amp;amp;in t ) {&lt;br /&gt;
	float M = 10000;&lt;br /&gt;
	AddPlayerBodyForce( 0, 2*M, 0, false );&lt;br /&gt;
	AddPlayerBodyForce( 0, 0, 0.7*M, true );&lt;br /&gt;
	PlayGuiSound( &amp;quot;step_run_female_rock.snt&amp;quot;, 0.4 );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0.7&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; M should be enough, remember this will run on every step. There's 5.&lt;br /&gt;
&lt;br /&gt;
5. Functionality&lt;br /&gt;
&lt;br /&gt;
This is the end of this guide. With this code you can experiment new functionalities and expand its possibilities.&amp;lt;br /&amp;gt;If you're interested, you can take a look at my code in any script file from my mod Riukka for more developed functions on wall running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;Amn.-&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>