tag:blogger.com,1999:blog-60010825855356616662024-02-19T02:49:34.340+01:00Gravity SpeedrunUDK game development from scratch, my thoughts, ideas, ups and downs encountered, some tips to ease your lifeAnonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-6001082585535661666.post-89594491768794336402014-01-23T07:58:00.000+01:002014-01-23T07:58:12.916+01:00Dungeons & NO Dragons<div class="separator" style="clear: both; text-align: center;">
<a href="https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-frc3/t31/1502741_678030662229188_544320257_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="96" src="https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-frc3/t31/1502741_678030662229188_544320257_o.jpg" width="400" /></a></div>
<br />
<br />
I'm proud to announce that the Prague project called <b>Kingdom Come</b> (medieval realistic rpg) I've been participating on for past 2,5 years is now on Kickstarter (and doing great!). If you like the idea of first person RPG without dragons and magicians, set in the historical Europe, check it out:<br />
<br />
<b>Kickstarter:</b> <a href="http://www.kickstarter.com/projects/1294225970/kingdom-come-deliverance">http://www.kickstarter.com/projects/1294225970/kingdom-come-deliverance</a><br />
<br />
<b>Official web page:</b> <a href="http://kingdomcomerpg.com/">http://kingdomcomerpg.com/</a><br />
<br />
<div style="text-align: center;">
<b>For our king! For honor! For glory!</b></div>
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-52826988107201513142013-12-02T08:49:00.002+01:002013-12-02T08:50:30.351+01:00The Mandate is successful!Thanks to all the backers and amazing community we did it, kickstarter campaign for The Mandate project was a success, we even met some stretch goals!<br />
<br />
<a href="http://www.kickstarter.com/projects/1964463742/the-mandate">http://www.kickstarter.com/projects/1964463742/the-mandate</a><br />
<br />
So big thanks goes to all the people that made this possible and now back to work!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmMP7Is48pRuDa3EKmGvR4F4dkFwBFIz2K215GZUuRMrtghhxyi08DAs8AeNhboNnNz3LoHR6TGUH29ZgEvDWokkADKKiJpjpkAQGQybkqQabvGePLan6YfJTIsGp9SSG91QaJqcHMrjEQ/s1600/Character_lineup_1080.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmMP7Is48pRuDa3EKmGvR4F4dkFwBFIz2K215GZUuRMrtghhxyi08DAs8AeNhboNnNz3LoHR6TGUH29ZgEvDWokkADKKiJpjpkAQGQybkqQabvGePLan6YfJTIsGp9SSG91QaJqcHMrjEQ/s400/Character_lineup_1080.jpg" width="400" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-37896092772128153812013-10-03T08:45:00.002+02:002013-10-03T08:47:52.497+02:00The Mandate<h2>
The Mandate is on Kickstarter!</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAW2sxOOSJAPRvrCKtd7pXiznzQLPWvVdLOXueLQGSFn08Jn3vIZmFW6ZiXnOOey9zZC8R8zksEax0Sk9v1yRJ8Bpy3C8AFD0_VZCUmMp03zEmf-BKUjVnuHnhiVQUZdUfZXfREMf2VTD7/s1600/mandate.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAW2sxOOSJAPRvrCKtd7pXiznzQLPWvVdLOXueLQGSFn08Jn3vIZmFW6ZiXnOOey9zZC8R8zksEax0Sk9v1yRJ8Bpy3C8AFD0_VZCUmMp03zEmf-BKUjVnuHnhiVQUZdUfZXfREMf2VTD7/s400/mandate.jpg" width="400" /></a></div>
<div>
<br /></div>
<div>
Hi guys! Recently I was quite busy helping friends with their space game (shaped in Unity), that is now on Kickstarter, please visit the page and if you find it interesting back their support!</div>
<div>
<br /></div>
<div>
<a href="http://www.kickstarter.com/projects/1964463742/the-mandate">http://www.kickstarter.com/projects/1964463742/the-mandate</a></div>
<div>
<br /></div>
<div>
We'd be more than happy if you spread the word a bit if you can. Furthermore there is a treat for everybody, shape your own ship and share your results on FB!</div>
<div>
<br /></div>
<div>
<a href="http://www.mandategame.com/mandateshipbuilder/shipbuilder.html">http://www.mandategame.com/mandateshipbuilder/shipbuilder.html</a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5SW49LFK661AQJoyP_EhdF0ojuOEH3HV7Z3o7ZjjmmyKtTAW-isF5gDvD5WpYyAuOzvNfmsxqkSlQYoGB5q8zfTUXQWota0nUf-yNQy0HC8b_mrTMhEcXeA8vJl2ZPgWY7s3psXgKq3MD/s1600/ship01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5SW49LFK661AQJoyP_EhdF0ojuOEH3HV7Z3o7ZjjmmyKtTAW-isF5gDvD5WpYyAuOzvNfmsxqkSlQYoGB5q8zfTUXQWota0nUf-yNQy0HC8b_mrTMhEcXeA8vJl2ZPgWY7s3psXgKq3MD/s320/ship01.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW9H7ymtpDEoJJd536tUQeqU9lghFu25w3CFdZfjj_geEn77V7HfBcCbwMxyIDQ1lbMyN8Ek7I6iKhMlnhC7_1eZG6vrLSCVs-oASzKm7Ag7yc4wdXZTEKpO8397ymtE-AT7AOxaeRPdFy/s1600/ship04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW9H7ymtpDEoJJd536tUQeqU9lghFu25w3CFdZfjj_geEn77V7HfBcCbwMxyIDQ1lbMyN8Ek7I6iKhMlnhC7_1eZG6vrLSCVs-oASzKm7Ag7yc4wdXZTEKpO8397ymtE-AT7AOxaeRPdFy/s320/ship04.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Thanks for your support!</div>
<div>
<br /></div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-33827542100233891682013-01-29T09:15:00.000+01:002013-01-29T15:46:06.228+01:00Diary: Co-op test level<div style="text-align: justify;">
<span style="font-family: inherit;">[UPDATE] You can download the co-op test level demo installer <a href="http://tinyurl.com/ak4vbxv" target="_blank">here</a>!</span><br />
<br />
After a small spin-off I've redesigned co-op gameplay and put up a small, yet complex level full of co-op goodies to proof the concept. Camera is top-down this time as good overview over the level is essential.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikuZA1DW0Mw1Y3s1GPq45N4ACKvorHLfY_NXu8QokY0UqVaCz9uMRoyd40c6iGTcm02E3EbQCdKsI7m7g84Bjs4DgMsY_sGmsj8NCHJAXTrAG-yZLXH3581fXHBePDcccVovWrzJ99mPVx/s1600/coop_level2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikuZA1DW0Mw1Y3s1GPq45N4ACKvorHLfY_NXu8QokY0UqVaCz9uMRoyd40c6iGTcm02E3EbQCdKsI7m7g84Bjs4DgMsY_sGmsj8NCHJAXTrAG-yZLXH3581fXHBePDcccVovWrzJ99mPVx/s400/coop_level2.png" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Basically level is an get from A to B variation, consisting of various challenges that require co-operation:<br />
<br />
<br />
<ul>
<li>two way buttons for opening doors (requires active presence of one pawn to open door for the other one)</li>
<li>different abilities of pawns (one is small enough to push through tight spaces, one is bigger and can carry items)</li>
<li>moving of platforms to create a bridge to cross the chasm, reach button, etc.</li>
<li>solving puzzles (correct sequence, subset, etc.)</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrgvzStOrxaSSXLXgpwKrkB76dgPmfoufVn9VdNs4zjySYFHE4dhk1vho2-EaUfpKkBta1yHQqIgrHW5Gsoi2vSp9yGRNt1pZiuR7cV96OwSdKuc88T2umKRymNGg1p7rL9rGsn92VLUpT/s1600/coop_level6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="385" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrgvzStOrxaSSXLXgpwKrkB76dgPmfoufVn9VdNs4zjySYFHE4dhk1vho2-EaUfpKkBta1yHQqIgrHW5Gsoi2vSp9yGRNt1pZiuR7cV96OwSdKuc88T2umKRymNGg1p7rL9rGsn92VLUpT/s400/coop_level6.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: inherit;">Level is heavily based on using prefabs, kismet and archetyped entities, which saves a lot of time. One completely new feature is a puzzle that gives you control over all the actors in an area, allowing you to move them around to achieve your goal (e.g. create a bridge to be able to pass over a pit).</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: inherit;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="font-family: inherit;">Don't forget to check the new videos on <a href="http://www.youtube.com/playlist?list=PLIoaN6ICizw02efa7aZs4RfGKhI-p7Lz5" target="_blank">youtube</a> as well! Two examples:</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/YNHqFJ0mbJM?feature=player_embedded' frameborder='0'></iframe></div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/aCB-0GrQhcg?feature=player_embedded' frameborder='0'></iframe></div>
<div style="text-align: center;">
<br /></div>
<br />
<div>
I hope you like it! In case you're interested in some technical background, I'm going to prepare and publish some tutorials based on my experience while working on this level soon!</div>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-64468295347778524382012-10-19T17:38:00.000+02:002012-10-19T17:38:04.306+02:00Diary: Co-op gameplayOne of the ideas of how to improve current game concept is to add co-op gameplay feel:<br />
<br />
<ul>
<li>multiple playable characters in a level, different set of skills</li>
<li>need to cooperate to reach the level goal</li>
<ul>
<li>e.g.: button at the end of small tunnell -> only smaller character can reach</li>
<li>movable objects -> only bigger character is strong enough, etc.</li>
</ul>
<li>possible gameplay variations:</li>
<ul>
<li><b>singleplayer</b> - switchable characters</li>
<li><b>multiplayer</b>:</li>
<ul>
<li><b>local co-op</b> - splitscreen</li>
<li><b>co-op</b></li>
</ul>
</ul>
</ul>
<div>
<br /></div>
<div>
Anyway, I'm back on track, pushing development on and on ;). Today I implemented possibility to have multiple playable characters in one level (switchable). To proof this concept I've prepared a small level, you can take a look at this video:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/KuEic0O1jag?feature=player_embedded' frameborder='0'></iframe></div>
<div>
<br /></div>
<div style="text-align: center;">
<b><i>Stay tuned for upcoming news!</i></b></div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com2tag:blogger.com,1999:blog-6001082585535661666.post-73530910202459026512012-10-18T10:49:00.003+02:002012-10-18T10:49:52.646+02:00Steam Greenlight & moving forward!<div style="text-align: justify;">
After being rather busy for the last few weeks doing my part time contract I'm back to UDK. I've some ideas I want to track and implement:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/dtQTuTLFBUA?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<h4>
Co-op basics:</h4>
<br />
<ul>
<li>two playable characters (ball-like robots)</li>
<li>each with differing set of skill (switching gravity, jumping, moving objects)</li>
<li>need to aid each other to finish a level</li>
<li>local co-op gameplay/controls/mechanics</li>
<li>switching between characters (to enable single player capabilities)</li>
</ul>
<div>
<i>Stay tuned for some news in the days to come!</i></div>
<div>
<i><br /></i></div>
<div>
<i><br /></i></div>
<h4>
Steam news:</h4>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwCeyb3vyuoMtQATCNdAGcQtdQFVNkrAq9dRTovY95O9NVwhxZCFrZTbA9F9Uhd_roSAgasyw87oIHxUenLF-S1RpE1A72c14rhPHNwbbLBLrIBXeNqE59a0-MKJxKc2iCn6981EpooWO/s1600/game_logo_steam.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwCeyb3vyuoMtQATCNdAGcQtdQFVNkrAq9dRTovY95O9NVwhxZCFrZTbA9F9Uhd_roSAgasyw87oIHxUenLF-S1RpE1A72c14rhPHNwbbLBLrIBXeNqE59a0-MKJxKc2iCn6981EpooWO/s320/game_logo_steam.jpg" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Furthermore, as <a href="http://store.steampowered.com/">Steam</a> has reintroduced it's Greenlight for free (new concepts section), you can find this project on <a href="http://steamcommunity.com/sharedfiles/filedetails/?id=103307809">steam site</a> now! In case you like it, feel free to endorse it or leave a comment. It is always appreciated to know what others are thinking. Thank you!</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-87862608256198664712012-10-16T08:36:00.000+02:002012-10-16T09:49:15.310+02:00Cookbook: UDK command lines<div style="text-align: justify;">
There are many things that can simplify your work and increase productivity. I think that in case of UDK that requires restarting editor and recompiling after each minor script change you can save some time by using batch files for starting everything you want without the need to manually open some level, etc.<br />
<br />
You can find some additional tips on getting started with UDK in <a href="http://gravityspeedrun.blogspot.sk/2012/09/cookbook-getting-started-with-udk.html">this tutorial</a>.</div>
<div style="text-align: justify;">
<br /></div>
So here are some useful command lines (use them in your batches):<br />
<ul>
<li>compile script</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode">call Binaries\Win64\UDK.exe make</pre>
<div>
<ul>
<li>run editor with your level + show log</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<pre class="csharpcode">call Binaries\Win64\UDK.exe editor YOUR_LEVEL_NAME -log -NoGADWarnings</pre>
</div>
<div>
<br /></div>
<div style="text-align: justify;">
Aforementioned command lines are for 64bit systems, in case you're using older 32bit systems, please replace <span style="font-family: Courier New, Courier, monospace;">Win64</span> with <span style="font-family: Courier New, Courier, monospace;">Win32</span><span style="font-family: inherit;">. Create those batches in your UDK install dir and put only a shortcut on your desktop to make it work with relative paths.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;"><b>Using UnrealFrontend:</b></span><br />
<span style="font-family: inherit;"><br /></span>
When packaging your game and cooking your levels you'll need to work with Unreal Frontend (<span style="font-family: Courier New, Courier, monospace;">%UDK_INSTALLDIR%\Binaries\UnrealFrontend.exe</span>).<br />
<br />
<ul>
<li>don't forget to have all your maps/levels listed in <span style="font-family: Courier New, Courier, monospace;">Maps to Cook</span> window prior to any cooking</li>
<li>don't forget to use <span style="font-family: Courier New, Courier, monospace;">Script/Full recompile</span> after changes to script</li>
<li>this has to be followed by <span style="font-family: Courier New, Courier, monospace;">Cook/Clean and Full Recook</span> of levels (to actually use changes in script)</li>
<li>after cooking, launch your game to make sure everything is intact and up to date</li>
<li>only after doing the check (in case everything is ok) do the actual packaging</li>
</ul>
<div>
<b><i>And last but not least, don't forget that you cannot compile scripts with editor running (this will cause compilation warnings and errors)!</i></b></div>
<br />
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-17897714767615576682012-10-15T07:17:00.000+02:002012-10-15T07:17:49.056+02:00Cookbook: Typecasting and utilizing class hierarchy<div style="text-align: justify;">
Even <span style="font-family: Courier New, Courier, monospace;">unrealscript</span> enables you to utilize inheritance and class hierarchy of your custom classes. So it is a good idea to design your actors/object in a way, that as much of the shared functionality and variables are in parental classes (to avoid copying the same code over and over) and be able to access that basic functionality after typecasting to a parent class (for example useful for storing all differing actors with same parent in one array and accessing them by their parent class...</div>
<br />
Let me show you all of this in an example:<br />
<br />
<div style="text-align: justify;">
Let's say we need a couple of types of platforms, one that turns on some lights, one that opens doors, one that gives player some points. What they have in common is a mesh and slight movement upon touch (to emulate being used). Additionally there is a class that stores a set of references to such platforms and handles global resetting, changing of states, etc.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
All the common functionality goes into some PlatformBase.uc:</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> PlatformBase extends Actor</pre>
<pre><span class="lnum"> 2: </span> placeable;</pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="rem">//our mesh</span></pre>
<pre><span class="lnum"> 5: </span><span class="kwrd">var</span> (StaticMesh) StaticMeshComponent StaticMesh;</pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span><span class="rem">/** movement offset from base position */</span></pre>
<pre><span class="lnum"> 8: </span><span class="kwrd">var</span>(Game) vector vMoveOffset;</pre>
<pre><span class="lnum"> 9: </span> </pre>
<pre><span class="lnum"> 10: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 11: </span>function TriggerAction()</pre>
<pre><span class="lnum"> 12: </span>{</pre>
<pre><span class="lnum"> 13: </span> <span class="rem">//move</span></pre>
<pre><span class="lnum"> 14: </span> SetLocation(Location + vMoveOffset);</pre>
<pre><span class="lnum"> 15: </span>}</pre>
<pre><span class="lnum"> 16: </span> </pre>
<pre><span class="lnum"> 17: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 18: </span>simulated <span class="kwrd">event</span> Reset()</pre>
<pre><span class="lnum"> 19: </span>{</pre>
<pre><span class="lnum"> 20: </span> <span class="rem">//reset</span></pre>
<pre><span class="lnum"> 21: </span> SetLocation(OrigLocation);</pre>
<pre><span class="lnum"> 22: </span> super.Reset();</pre>
<pre><span class="lnum"> 23: </span>}</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In the inherited classes you only need to add additional functionality, all the functionality of parental class is intact and can be used:</div>
<div style="text-align: justify;">
<br />
PlatformPoints.uc:</div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> PlatformPoints extends PlatformBase</pre>
<pre><span class="lnum"> 2: </span> placeable;</pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 5: </span>function TriggerAction()</pre>
<pre><span class="lnum"> 6: </span>{</pre>
<pre><span class="lnum"> 7: </span> super.TriggerAction(); <span class="rem">//call parent method (move platform)</span></pre>
<pre><span class="lnum"> 8: </span> </pre>
<pre><span class="lnum"> 9: </span> PlayerController.AddPoints(100); <span class="rem">//add some points</span></pre>
<pre><span class="lnum"> 10: </span>}</pre>
</div>
<br />
PlatformLight.uc:<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> PlatformLight extends PlatformBase</pre>
<pre><span class="lnum"> 2: </span> placeable;</pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="kwrd">var</span>(Light) <span class="kwrd">const</span> LightComponent Light;</pre>
<pre><span class="lnum"> 5: </span> </pre>
<pre><span class="lnum"> 6: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 7: </span>function TriggerAction()</pre>
<pre><span class="lnum"> 8: </span>{</pre>
<pre><span class="lnum"> 9: </span> super.TriggerAction(); <span class="rem">//call parent method (move platform)</span></pre>
<pre><span class="lnum"> 10: </span> </pre>
<pre><span class="lnum"> 11: </span> Light.SetEnabled(<span class="kwrd">true</span>); <span class="rem">//enable referenced light</span></pre>
<pre><span class="lnum"> 12: </span>}</pre>
<pre><span class="lnum"> 13: </span> </pre>
<pre><span class="lnum"> 14: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 15: </span>simulated <span class="kwrd">event</span> Reset()</pre>
<pre><span class="lnum"> 16: </span>{</pre>
<pre><span class="lnum"> 17: </span> super.Reset(); <span class="rem">//call parent method</span></pre>
<pre><span class="lnum"> 18: </span> </pre>
<pre><span class="lnum"> 19: </span> Light.SetEnabled(<span class="kwrd">false</span>); <span class="rem">//reset light state</span></pre>
<pre><span class="lnum"> 20: </span>}</pre>
</div>
<br />
PlatformDoor.uc:
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> PlatformDoor extends PlatformBase</pre>
<pre><span class="lnum"> 2: </span> placeable;</pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 5: </span>function TriggerAction()</pre>
<pre><span class="lnum"> 6: </span>{</pre>
<pre><span class="lnum"> 7: </span> super.TriggerAction(); <span class="rem">//call parent method (move platform)</span></pre>
<pre><span class="lnum"> 8: </span> </pre>
<pre><span class="lnum"> 9: </span> <span class="rem">//trigger event with myself as instigator</span></pre>
<pre><span class="lnum"> 10: </span> TriggerEventClass(<span class="kwrd">class</span><span class="str">'SeqEvent_DoorOpen'</span>, self);</pre>
<pre><span class="lnum"> 11: </span>}</pre>
<pre><span class="lnum"> 12: </span> </pre>
<pre><span class="lnum"> 13: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 14: </span>simulated <span class="kwrd">event</span> Reset()</pre>
<pre><span class="lnum"> 15: </span>{</pre>
<pre><span class="lnum"> 16: </span> super.Reset(); <span class="rem">//call parent method</span></pre>
<pre><span class="lnum"> 17: </span> </pre>
<pre><span class="lnum"> 18: </span> <span class="rem">//trigger event with myself as instigator</span></pre>
<pre><span class="lnum"> 19: </span> TriggerEventClass(<span class="kwrd">class</span><span class="str">'SeqEvent_DoorClose'</span>, self);</pre>
<pre><span class="lnum"> 20: </span>}</pre>
</div>
<div style="text-align: justify;">
<br />
The handler class than collects references to all platforms by their parental class and can access all the basic functionality or typecast it to inherited class to use additional functionality. <i>And remember accessing basic functionality of class referenced by its parental class actually calls the overriden method of actual class!</i></div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> PlatformHandler extends Actor;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">//references to all platforms</span></pre>
<pre><span class="lnum"> 4: </span><span class="kwrd">var</span> array<PlatformBase> Platforms;</pre>
<pre><span class="lnum"> 5: </span> </pre>
<pre><span class="lnum"> 6: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 7: </span><span class="kwrd">event</span> PostBeginPlay()</pre>
<pre><span class="lnum"> 8: </span>{</pre>
<pre><span class="lnum"> 9: </span> local PlatformBase platform;</pre>
<pre><span class="lnum"> 10: </span> </pre>
<pre><span class="lnum"> 11: </span> <span class="rem">//iterate over all actors with exact or parental class of PlatformBase</span></pre>
<pre><span class="lnum"> 12: </span> <span class="kwrd">foreach</span> WorldInfo.DynamicActors(<span class="kwrd">class</span><span class="str">'PlatformBase'</span>, platform)</pre>
<pre><span class="lnum"> 13: </span> {</pre>
<pre><span class="lnum"> 14: </span> Platforms.AddItem(platform); <span class="rem">//store reference</span></pre>
<pre><span class="lnum"> 15: </span> }</pre>
<pre><span class="lnum"> 16: </span>}</pre>
<pre><span class="lnum"> 17: </span> </pre>
<pre><span class="lnum"> 18: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 19: </span>function ResetActors()</pre>
<pre><span class="lnum"> 20: </span>{</pre>
<pre><span class="lnum"> 21: </span> local PlatformBase platform;</pre>
<pre><span class="lnum"> 22: </span> local PlatformDoor door;</pre>
<pre><span class="lnum"> 23: </span> </pre>
<pre><span class="lnum"> 24: </span> <span class="rem">//reset all platforms</span></pre>
<pre><span class="lnum"> 25: </span> <span class="kwrd">foreach</span> Platforms(platform)</pre>
<pre><span class="lnum"> 26: </span> {</pre>
<pre><span class="lnum"> 27: </span> <span class="rem">//call the reset </span></pre>
<pre><span class="lnum"> 28: </span> <span class="rem">//(this will call actual reset of real platform class type!)</span></pre>
<pre><span class="lnum"> 29: </span> platform.Reset();</pre>
<pre><span class="lnum"> 30: </span> </pre>
<pre><span class="lnum"> 31: </span> <span class="rem">//you can even typecast to some inherited type</span></pre>
<pre><span class="lnum"> 32: </span> door = (PlatformDoor)platform;</pre>
<pre><span class="lnum"> 33: </span> </pre>
<pre><span class="lnum"> 34: </span> <span class="kwrd">if</span> (door != none) <span class="rem">//success, this one is really platformDoor</span></pre>
<pre><span class="lnum"> 35: </span> {</pre>
<pre><span class="lnum"> 36: </span> <span class="rem">//call method unique for PlatformDoor!</span></pre>
<pre><span class="lnum"> 37: </span> door.StringToHUD(<span class="str">"door opening!"</span>);</pre>
<pre><span class="lnum"> 38: </span> }</pre>
<pre><span class="lnum"> 39: </span> }</pre>
<pre><span class="lnum"> 40: </span>}</pre>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-18071344616325609152012-10-12T10:11:00.001+02:002012-10-12T10:11:46.752+02:00Cookbook: Referencing objects<div style="text-align: center;">
<i>"I'm trying to call a certain function of Controller from a different class. How can I do it?"</i></div>
<div style="text-align: center;">
<i><br /></i></div>
<div style="text-align: left;">
<div style="text-align: justify;">
There are situations when you need to call a method of a different class (update stats, test some conditions, display something on the HUD) from your custom actor. As in UDK the centerpiece of all action handling is the <span style="font-family: Courier New, Courier, monospace;">Controller</span> class, you may need to store reference to it in your actors that change somehow gameplay status.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To set this reference you can use a simple iteration approach (iterate over all actors of some class):</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Controller.uc:</div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">var</span> array<CustomActor> Actors;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 4: </span><span class="kwrd">event</span> PostBeginPlay()</pre>
<pre><span class="lnum"> 5: </span>{</pre>
<pre><span class="lnum"> 6: </span> local CustomActor actor;</pre>
<pre><span class="lnum"> 7: </span> </pre>
<pre><span class="lnum"> 8: </span> <span class="kwrd">foreach</span> WorldInfo.DynamicActors(<span class="kwrd">class</span><span class="str">'CustomActor'</span>, actor)</pre>
<pre><span class="lnum"> 9: </span> {</pre>
<pre><span class="lnum"> 10: </span> actor.Controller = self; <span class="rem">//set myself as controller</span></pre>
<pre><span class="lnum"> 11: </span> Actors.AddItem(actor); <span class="rem">//store reference</span></pre>
<pre><span class="lnum"> 12: </span> }</pre>
<pre><span class="lnum"> 13: </span>}</pre>
<pre><span class="lnum"> 14: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 15: </span>function Disable()</pre>
<pre><span class="lnum"> 16: </span>{</pre>
<pre><span class="lnum"> 17: </span> local PuzzleActorBase actor;</pre>
<pre><span class="lnum"> 18: </span> </pre>
<pre><span class="lnum"> 19: </span> <span class="rem">//disable all parts (use stored references)</span></pre>
<pre><span class="lnum"> 20: </span> <span class="kwrd">foreach</span> Actors(actor)</pre>
<pre><span class="lnum"> 21: </span> {</pre>
<pre><span class="lnum"> 22: </span> actor.DisableActor();</pre>
<pre><span class="lnum"> 23: </span> }</pre>
<pre><span class="lnum"> 24: </span>}</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This way you can later call methods of you controller when actor is touched/triggered/hit, etc.:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br />
<div>
CustomActor.uc:</div>
<div style="text-align: left;">
</div>
<div class="csharpcode" style="text-align: left;">
<pre><span class="lnum"> 1: </span><span class="kwrd">var</span> CustomHandler Controller;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 4: </span>function UpdateTriggered() <span class="rem">//some method</span></pre>
<pre><span class="lnum"> 5: </span>{</pre>
<pre><span class="lnum"> 6: </span> <span class="kwrd">if</span> (Controller != none)</pre>
<pre><span class="lnum"> 7: </span> {</pre>
<pre><span class="lnum"> 8: </span> <span class="rem">//use reference</span></pre>
<pre><span class="lnum"> 9: </span> Controller.TriggerAction(self);</pre>
<pre><span class="lnum"> 10: </span> }</pre>
<pre><span class="lnum"> 11: </span>}</pre>
</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This can be of course generalized and reused for other situations. Let's say we have a handler class that stores references to all objects of some type (or inside some volume) and evaluates some logic (push platforms that are a part of some puzzle and handler that checks if they are pushed in some order, etc.). This handler can also iterate over all necessary objects and store references to desired objects....</div>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-34525602586806870562012-10-11T08:36:00.000+02:002012-10-11T08:36:39.349+02:00Cookbook: Custom input bindings<div style="text-align: justify;">
In case you're not simply extending some <span style="font-family: Courier New, Courier, monospace;">UTGame</span> and creating another clone of a shooter (which UDK is rather streamlined for) sooner or later you'll need to extend controls setup/rebind input keys, etc.</div>
<br />
<div style="text-align: justify;">
I recommend to create a <b>custom input config</b>, where you can keep only things you really need and avoid problems with upgrading to newer versions of UDK (conflicts while merging your changes to those from Epic). Apart from that you'll avoid problem with overriding bindings (last appearance of binding disables all bindings to the same key found anywhere before in the hierarchy of config files!). As with all other config files in UDK, create Default version of your input config (UDK version is going to be created automatically when launching editor):</div>
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>[BallPuzzler.BallPuzzlerInput]</pre>
<pre><span class="lnum"> 2: </span>; types <span class="rem">//this is just a comment</span></pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="rem">//alias for binding command (reused for PC/XBOX in the same config)</span></pre>
<pre><span class="lnum"> 5: </span> <span class="rem">//name to identify //command to exectute</span></pre>
<pre><span class="lnum"> 6: </span>Bindings=(Name=<span class="str">"GBA_ShowMenu"</span>,Command=<span class="str">"CloseEditorViewport | onrelease ShowMenu"</span>)</pre>
<pre><span class="lnum"> 7: </span> </pre>
<pre><span class="lnum"> 8: </span>; pc</pre>
<pre><span class="lnum"> 9: </span> <span class="rem">//key pressed, command to execute</span></pre>
<pre><span class="lnum"> 10: </span>Bindings=(Name=<span class="str">"X"</span>,Command=<span class="str">"ToggleZoom"</span>)</pre>
<pre><span class="lnum"> 11: </span>...</pre>
<pre><span class="lnum"> 12: </span> </pre>
<pre><span class="lnum"> 13: </span><span class="rem">//use previously defined alias</span></pre>
<pre><span class="lnum"> 14: </span>Bindings=(Name=<span class="str">"Escape"</span>,Command=<span class="str">"GBA_ShowMenu"</span>)</pre>
<pre><span class="lnum"> 15: </span> </pre>
<pre><span class="lnum"> 16: </span>; xbox</pre>
<pre><span class="lnum"> 17: </span> <span class="rem">//key pressed, command to execute</span></pre>
<pre><span class="lnum"> 18: </span>Bindings=(Name=<span class="str">"XboxTypeS_Y"</span>,Command=<span class="str">"ToggleZoom"</span>)</pre>
<pre><span class="lnum"> 19: </span> </pre>
<pre><span class="lnum"> 20: </span>...</pre>
<pre><span class="lnum"> 21: </span> </pre>
<pre><span class="lnum"> 22: </span><span class="rem">//use previously defined alias</span></pre>
<pre><span class="lnum"> 23: </span>Bindings=(Name=<span class="str">"XboxTypeS_Start"</span>,Command=<span class="str">"GBA_ShowMenu"</span>)</pre>
</div>
<br />
To use custom input config you need to do two additional steps:<br />
<br />
<ul>
<li>create an extension to <span style="font-family: Courier New, Courier, monospace;">PlayerInput</span> class with config file specified:</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> BallPuzzlerInput extends PlayerInput within BallPuzzlerController</pre>
<pre><span class="lnum"> 2: </span> config(BallPuzzlerInput);</pre>
</div>
<div>
<br /></div>
<div>
<ul>
<li>setup it in your controller class (<span style="font-family: Courier New, Courier, monospace;">defaultProperties</span>):</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//======================================================================= </span></pre>
<pre><span class="lnum"> 2: </span>defaultProperties</pre>
<pre><span class="lnum"> 3: </span>{</pre>
<pre><span class="lnum"> 4: </span> InputClass=<span class="kwrd">class</span><span class="str">'BallPuzzlerInput'</span>;</pre>
<pre><span class="lnum"> 5: </span> </pre>
<pre><span class="lnum"> 6: </span> ...</pre>
<pre><span class="lnum"> 7: </span>}</pre>
</div>
<div>
<br /></div>
</div>
<br />
<br />
Later you can react (in you controller class) on custom commands being executed:<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 2: </span>exec function ToggleZoom() <span class="rem">//is triggered according to config key binding</span></pre>
<pre><span class="lnum"> 3: </span>{</pre>
<pre><span class="lnum"> 4: </span> <span class="rem">//some code you want to run when X/XboxTypeS_Y is pressed</span></pre>
<pre><span class="lnum"> 5: </span> ...</pre>
<pre><span class="lnum"> 6: </span>}</pre>
</div>
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-73997604632751330342012-10-10T08:36:00.005+02:002012-10-10T10:32:33.174+02:00Cookbook: Custom postprocess chain<div style="text-align: justify;">
In Unreal postprocess effects are set per level (<span style="font-family: Courier New, Courier, monospace;">WorldProperties/Default Postprocess Settings</span>). But what if you want to have the same atmospheric setting for many of your levels? There comes the possibity to specify your custom <span style="font-family: Courier New, Courier, monospace;">PostProcessChain</span> and reuse it in every level where you want it to be (and edit settings of all such levels just by tweaking one<span style="font-family: Courier New, Courier, monospace;"> PostProcessChain</span>).</div>
<br />
What do you need to set it?<br />
<br />
<ul>
<li style="text-align: justify;">create empty <span style="font-family: Courier New, Courier, monospace;">PostProcessChain</span> (right click in <span style="font-family: Courier New, Courier, monospace;">Content Browser</span> -> <span style="font-family: Courier New, Courier, monospace;">New PostProcessChain</span>, specify package name, etc.</li>
<li style="text-align: justify;">setup your postprocess (double click on <span style="font-family: Courier New, Courier, monospace;">PostProcessChain</span>):</li>
<ul>
<li style="text-align: justify;">you can specify a chain of different nodes (like in kismet) where output of the previous node is the input for the next one</li>
<li style="text-align: justify;"><span style="font-family: Courier New, Courier, monospace;">UberPostProcessEffect</span> lets you specify almost everything that is being set in aforementioned <span style="font-family: Courier New, Courier, monospace;">Default Postprocess Settings</span></li>
<li style="text-align: justify;"><span style="font-family: Courier New, Courier, monospace;">MaterialEffect</span> lets you use any screenspace shader you want</li>
</ul>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkAtRRXbs-SPzs-A3pnn5IWUfULPhszY1I4CgKhh_cuB9RClqC7Kx6LliqValEF6MfSR81mFin2Dd5Sg-Y0sv48j8zk7N7aSoLNiwm0MI8N1t03ncE79LusM35zlvPBLvsSOIi0fbfQtJu/s1600/postprocess_02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="139" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkAtRRXbs-SPzs-A3pnn5IWUfULPhszY1I4CgKhh_cuB9RClqC7Kx6LliqValEF6MfSR81mFin2Dd5Sg-Y0sv48j8zk7N7aSoLNiwm0MI8N1t03ncE79LusM35zlvPBLvsSOIi0fbfQtJu/s320/postprocess_02.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<ul>
<li>use it in level:</li>
<ul>
<li style="text-align: justify;">just select your new chain and use it in <span style="font-family: Courier New, Courier, monospace;">WorldProperties/World Post Process Chain</span></li>
</ul>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcEwOkh2FIFsw_2CiVWdJRQHRGMCBTqDIlmSc5T3hGc-tN5uMI161J2K3lDU-efrBg4dw7jIFIYT9Ze4jy0uv3y_HDWP2yCRlFtEcAJdMLEgfByo-VRKJFhoUoHcp2UIWOuU8ppqIibQ8N/s1600/postprocess_01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcEwOkh2FIFsw_2CiVWdJRQHRGMCBTqDIlmSc5T3hGc-tN5uMI161J2K3lDU-efrBg4dw7jIFIYT9Ze4jy0uv3y_HDWP2yCRlFtEcAJdMLEgfByo-VRKJFhoUoHcp2UIWOuU8ppqIibQ8N/s320/postprocess_01.png" width="320" /></a></div>
<div style="text-align: justify;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
</div>
<div style="text-align: justify;">
<ul>
<li><span style="font-family: inherit;">you can preview all parts of effect chain directly while in editor:</span></li>
<ul>
<li><span style="font-family: inherit;">either use Post process effect/Show in editor checkbox directly in properties of individual nodes</span></li>
<li><span style="font-family: inherit;">or click on </span><span style="font-family: Courier New, Courier, monospace;">Game View</span><span style="font-family: inherit;"> button on your viewport panel (big </span><span style="font-family: Courier New, Courier, monospace;">G</span><span style="font-family: inherit;">)</span></li>
</ul>
</ul>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij-3JAg5qcFs9eISMdHn4_XaQBlemSEf4yf0x3EXYB1X7CiTCq9SS3TEWhwCMuZLGaMND4Rz3DYpxFNxhvAe0Lh0xUoUjY-mV9r_-9kJQJ1IMfoUI_zr6RqX8EqcLhJdR6MKgO-Hw9t0UV/s1600/postprocess_off.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij-3JAg5qcFs9eISMdHn4_XaQBlemSEf4yf0x3EXYB1X7CiTCq9SS3TEWhwCMuZLGaMND4Rz3DYpxFNxhvAe0Lh0xUoUjY-mV9r_-9kJQJ1IMfoUI_zr6RqX8EqcLhJdR6MKgO-Hw9t0UV/s320/postprocess_off.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Postprocess off</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOu2ayJN3ndioIHbAtrMvrkaXvzDWZ41_sPYdM1ISKjU6hOVFFTsbniqF3WxO80_yM3wR1srUJ13840pean15m6IBMYuqIzB3BLPqrpN4GPL74G8hrW3FXpfYpYi6dFL0l1DgY4uqXwhyY/s1600/postprocess_on.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOu2ayJN3ndioIHbAtrMvrkaXvzDWZ41_sPYdM1ISKjU6hOVFFTsbniqF3WxO80_yM3wR1srUJ13840pean15m6IBMYuqIzB3BLPqrpN4GPL74G8hrW3FXpfYpYi6dFL0l1DgY4uqXwhyY/s320/postprocess_on.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Postprocess on</td></tr>
</tbody></table>
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-3115632777107969792012-10-09T08:52:00.004+02:002012-10-09T08:52:40.965+02:00Cookbook: actionscript -> kismet commands with parameters<div style="text-align: justify;">
At some point in your project, you'd like to create some nice menu and be able to load different levels, setup resolutions, etc. Let me show you the way how to simply do it and additionally use utilize parameters as well.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuLsZzWfRqbmUqk0rABhfdZqZDzkQ0EaPwij1_y54XISFPfsPC82NrIA78rIKCCCXUSs7RdYaOQYw_rKqd1N6BPjvnyeriI9eNadZvjx1eRiSpQx3JnQeaAREy92stby56sYpdDp1-kRjq/s1600/simple_menu.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuLsZzWfRqbmUqk0rABhfdZqZDzkQ0EaPwij1_y54XISFPfsPC82NrIA78rIKCCCXUSs7RdYaOQYw_rKqd1N6BPjvnyeriI9eNadZvjx1eRiSpQx3JnQeaAREy92stby56sYpdDp1-kRjq/s320/simple_menu.png" width="320" /></a></div>
<br /></div>
<br />
<div style="text-align: justify;">
For my <a href="http://gravityspeedrun.blogspot.sk/2012/10/project-demo-installer.html">demo installer</a> I needed some simple menu (possibility to choose from a set of levels and change resolution for older HW/notebooks). I didn't have much time to play with <span style="font-family: Courier New, Courier, monospace;">Scaleform</span> and so I've chosen <span style="font-family: Courier New, Courier, monospace;">actionscript 2.0</span> approach that was more familiar to me. Easiest way to send a string command to unreal is by using <span style="font-family: Courier New, Courier, monospace;">fscommand.</span></div>
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>buttonLevel[i].onPress = function() {</pre>
<pre><span class="lnum"> 2: </span> <span class="rem">//command to be linked with kismet node</span></pre>
<pre><span class="lnum"> 3: </span> <span class="rem">//actual command we want to run in kismet</span></pre>
<pre><span class="lnum"> 4: </span> fscommand(<span class="str">"loadmap"</span>,<span class="str">"open "</span> + levelNames[<span class="kwrd">this</span>.id]);</pre>
<pre><span class="lnum"> 5: </span>};</pre>
</div>
<br />
<br />
<div style="text-align: justify;">
This method can additionally have a string of parameters that can be parsed/used in kismet to avoid necessity to creating separate kismet nodes for generic tasks (e.g. open level1, open level2, ... open level37). If you're curious how to react on such a command on unreal side, utilize kismet event node <span style="font-family: Courier New, Courier, monospace;">FsCommand </span>(<span style="font-family: Courier New, Courier, monospace;">New Event/Gfx UI/FsCommand</span>). This node has an optional argument that can be sent to any other kismet action (e.g. <span style="font-family: Courier New, Courier, monospace;">Console Command</span> for opening levels).</div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgujRSwWl3ppNVt_3esIaspaN7lTR-6rrSr_e5hyH_QUn_Ao1K_1K-OUpZVqIURBmsvW6Dvjal_llyAwM48GYbmHMloIWQrOi88qQpqFJ-S-Bn0dqM8eYk19UqK1nsb_qKDswdW9sGv6ju/s1600/fscommand.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgujRSwWl3ppNVt_3esIaspaN7lTR-6rrSr_e5hyH_QUn_Ao1K_1K-OUpZVqIURBmsvW6Dvjal_llyAwM48GYbmHMloIWQrOi88qQpqFJ-S-Bn0dqM8eYk19UqK1nsb_qKDswdW9sGv6ju/s320/fscommand.png" width="320" /></a></div>
<br />
<br />
FsCommand node requires its parameter fsCommand to be set to string that links it with actual fscommand sent from action script.<br />
<br />
<div style="text-align: justify;">
So in our case for example for opening levels we send fscommand from scaleform with argument (easier to compose it in actionscript than in kismet) that is the actual command to run in kismet and in kismet we just link this string argument and use it in another kismet action. Nevertheless we are sufficient with simple kismet node setup without the necessity to create a separate scheme (and devise separate command names) for each new level to load/resolution to set, etc.</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-32114824759671267062012-10-08T10:17:00.001+02:002012-10-08T10:17:19.027+02:00Cookbook: Prefabs<div style="text-align: justify;">
Ever wondering how to compose some complex set of meshes with animations, sound effects, particles into one object with ability of easy instancing? Well, in this case <span style="font-family: Courier New, Courier, monospace;">Prefabs </span>are just what you are looking for!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
You can create them easily in UnrealEd and reuse wherever you need them without the need to painfully copy kismet schemes, setting all the different parameters, etc. And of course you can decompose your prefab, change a few things and create another version for later reuse.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Let's say we want to have doors that are opened by a button/lever (that requires at least button actor, door interpactor, matinee for doors and kismet assemble). Quite a lot to handle repeatedly if you can just instance one composed prefab instead ;). Here is an example how to create given prefab in editor:</div>
<br />
<br />
<ul>
<li>insert individual meshes/archetypes for both button and door</li>
</ul>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZcv-Ajtcw_sqk46UZ_jnRmIKrHCePPXc-zzHDvIFrzxLmijaCHr25kh1HlCeJN4y0jLzUTjCDHDbu-QIwbYoATjNDsFHn12aB3jpeGEurFnm4hrnS8Kdf9mJsOzGWkZ2Dja-pTZ-c5m4h/s1600/prefab_01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZcv-Ajtcw_sqk46UZ_jnRmIKrHCePPXc-zzHDvIFrzxLmijaCHr25kh1HlCeJN4y0jLzUTjCDHDbu-QIwbYoATjNDsFHn12aB3jpeGEurFnm4hrnS8Kdf9mJsOzGWkZ2Dja-pTZ-c5m4h/s320/prefab_01.png" width="320" /></a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<ul>
<li>prepare kismet setup and simple matinee with movement track for door <span style="font-family: Courier New, Courier, monospace;">InterpActor</span></li>
</ul>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU0ai293z4AKmwjFDC0fMN618SdmOkUcuDrSBfJl02C88VKhjEJJQtKCiU_uWR9sMyOQXKjKZjGL3uUVtuJyFSJzG9_u_gI1w3yP7M6cP2HPBmFLf_IR6Cc3VKN_flR7fPTUoGphYUSTXc/s1600/prefab_02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU0ai293z4AKmwjFDC0fMN618SdmOkUcuDrSBfJl02C88VKhjEJJQtKCiU_uWR9sMyOQXKjKZjGL3uUVtuJyFSJzG9_u_gI1w3yP7M6cP2HPBmFLf_IR6Cc3VKN_flR7fPTUoGphYUSTXc/s320/prefab_02.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<ul>
<li style="text-align: justify;">with all individual parts set and selected, right click and choose <span style="font-family: Courier New, Courier, monospace;">Create Prefab...</span> option. Choose package name, etc. and select Yes for prompt to found kismet sequence (to make it part of prefab) and replacing individual actors in scene with prefab. From now on you can insert another instances of this prefab setup from your Content Browser (and of course position/rotate them differently to work appropriately in your level).</li>
</ul>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbHusJ3B9psLl3f8J0wtMHSlpjHcBQ4pREmjchrOnH6jOVm8fYZXg-12J5OD2VGOeDXxpAmI8pZhnoUs8OQuOZ0NE3YbdE_9PQMQogOmrQwDjuqZai7aoLezyb8DxQE4ZnHrfEmK0Mz12z/s1600/prefab_03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbHusJ3B9psLl3f8J0wtMHSlpjHcBQ4pREmjchrOnH6jOVm8fYZXg-12J5OD2VGOeDXxpAmI8pZhnoUs8OQuOZ0NE3YbdE_9PQMQogOmrQwDjuqZai7aoLezyb8DxQE4ZnHrfEmK0Mz12z/s320/prefab_03.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<ul>
<li style="text-align: justify;">in case you need to change some parts of prefab, select its instance and right click, <span style="font-family: Courier New, Courier, monospace;">Convert PrefabInstance To Normal Actors</span>, update, create different version of prefab, etc.</li>
</ul>
</div>
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-34888265110401042412012-10-08T07:59:00.000+02:002012-10-08T07:59:35.201+02:00Project demo (installer)<div style="text-align: justify;">
In case you'd like to try my current very early version of the project, grab installer from this site: <a href="http://tinyurl.com/9pkgq8t">http://tinyurl.com/9pkgq8t</a>.</div>
<br />
Basically you'll get stuff covered in this video:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/97nCp7DnyqE?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<div style="text-align: justify;">
It can be played on keyboard or using X360 gamepad. All controls are shown on HUD, I hope gameplay itself is rather self explanatory, goal of each level is to collect given number of coins. Stored local leaderboards let you replay the level and try to achieve better time, or fewer steps, etc.</div>
<br />
<div style="text-align: justify;">
Demo contains 3 levels with differing gameplay, it's a bit shaky and physics tends to be very fragile but maybe you will find it interesting and can definitely share some ideas, what you did like, what not, etc. Any comments are appreciated!</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-14471358521567709482012-10-05T17:01:00.000+02:002012-10-05T17:02:34.209+02:00Cookbook: Sidescroller-like first person view<i>"I want to make a game like a Sidescroller but in first-person view. So you can only walk forward and backward and jump. No strafe to the left or right."</i><br />
<br />
Based on this question in <a href="http://forums.epicgames.com/threads/928671-Sidescroller-in-first-person-!">epicgames forums</a>, I've taken some time to create a simple solution (not superb, partially hardcoded, but you can continue from that) for anybody interested :).<br />
<br />
Here we go:<br />
<br />
<span style="font-family: inherit;">I'll base all code changes on this cool tutorial for <i>Sidescroller</i>: <a href="http://udn.epicgames.com/Three/DevelopmentKitGemsPlatformerStarterKit.html">http://udn.epicgames.com/Three/DevelopmentKitGemsPlatformerStarterKit.html</a></span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">What we need to do is:</span><br />
<ul>
<li><span style="font-family: inherit;">Update camera behavior so it is positioned in front of pawn and points in direction of positive Y axis</span></li>
<ul>
<li><span style="font-family: inherit;">first part can be done in archetyped </span><span style="font-family: Courier New, Courier, monospace;">CameraProperties </span><span style="font-family: inherit;">directly in Editor:</span></li>
</ul>
</ul>
<div style="text-align: justify;">
<span style="font-family: inherit;">Experiment with </span><span style="font-family: Courier New, Courier, monospace;">StarterPlatformGameContent</span><span style="font-family: inherit;"> package (Content browser in editor) and change </span><span style="font-family: Courier New, Courier, monospace;">CameraProperties.CameraOffset</span><span style="font-family: inherit;"> vector:</span></div>
<span style="font-family: inherit;"><b><i>FPS like view</i></b> (X=0,Y=10,Z=50) -> camera slightly in front of pawn model, only weapon visible</span><br />
<span style="font-family: inherit;"><b><i>over the arm camera</i></b> (X=-20,Y=-20,Z=50) -> head, arms and weapon visible</span><br />
<ul><ul>
<li>second part requires simple code change (<span style="font-family: Courier New, Courier, monospace;">SPG_Camera.uc</span>):</li>
</ul>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>function UpdateViewTarget(<span class="kwrd">out</span> TViewTarget OutVT, <span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 2: </span>{</pre>
<pre><span class="lnum"> 3: </span> ...</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span> <span class="rem">// Make the camera point towards the target's location</span></pre>
<pre><span class="lnum"> 6: </span> <span class="rem">//REPLACE THIS:</span></pre>
<pre><span class="lnum"> 7: </span> //<span class="rem">OutVT.POV.Rotation = Rotator(OutVT.Target.Location - OutVT.POV.Location);</span></pre>
<pre><span class="lnum"> 8: </span> </pre>
<pre><span class="lnum"> 9: </span> <span class="rem">//WITH THIS:</span></pre>
<pre><span class="lnum"> 10: </span> <span class="rem">//camera rotated to point in positive Y axis direction</span></pre>
<pre><span class="lnum"> 11: </span> OutVT.POV.Rotation = Rotator(vect(0,100,0));</pre>
<pre><span class="lnum"> 12: </span>}</pre>
</div>
<br />
<ul>
<li>update player input computation method to react on forward/backward keys (<span style="font-family: Courier New, Courier, monospace;">SPG_PlayerController.uc</span>):</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>function PlayerMove(<span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 2: </span>{</pre>
<pre><span class="lnum"> 3: </span> ...</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span> <span class="rem">//CHANGE THIS:</span></pre>
<pre><span class="lnum"> 6: </span> NewAccel = PlayerInput.aStrafe * Y;</pre>
<pre><span class="lnum"> 7: </span> </pre>
<pre><span class="lnum"> 8: </span> <span class="rem">//INTO THIS:</span></pre>
<pre><span class="lnum"> 9: </span> <span class="rem">//aBaseY input is moving forward/backward, we want pawn to move along Y axis</span></pre>
<pre><span class="lnum"> 10: </span> NewAccel = PlayerInput.aBaseY * vect(0,1,0);</pre>
<pre><span class="lnum"> 11: </span> </pre>
<pre><span class="lnum"> 12: </span> ...</pre>
<pre><span class="lnum"> 13: </span>}</pre>
</div>
<br />
<br />
<ul>
<li><span style="font-family: inherit;">Compile, run, experiment :)!</span></li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwts0s4qI_BMMhGJLPg227gWrsdZKQ3okFRz50-xLQDZ11sz7YlSQBY3nIvl8qTckWaXmtBLmuV88kp6u1UOOtBhaTKbwAvwJCC3U5Q0BEXSrHQsuSxX_QozEPQaiuTSKQcAgxqIKTttr3/s1600/fps_sidescroller01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="187" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwts0s4qI_BMMhGJLPg227gWrsdZKQ3okFRz50-xLQDZ11sz7YlSQBY3nIvl8qTckWaXmtBLmuV88kp6u1UOOtBhaTKbwAvwJCC3U5Q0BEXSrHQsuSxX_QozEPQaiuTSKQcAgxqIKTttr3/s320/fps_sidescroller01.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEvUZV4W7eOznA9WvSP1anOSaHFnWHBUcUUbVyoSEz1UuxfkOYRYFxttqeTuBOJwqQVtR8KvR4yUaTTszqKBps9NnQz5wHRpChR2xmKy3Uabt2L8hrciX-YQr2rDHh8cp998X29ZKuOeex/s1600/fps_sidescroller02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="187" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEvUZV4W7eOznA9WvSP1anOSaHFnWHBUcUUbVyoSEz1UuxfkOYRYFxttqeTuBOJwqQVtR8KvR4yUaTTszqKBps9NnQz5wHRpChR2xmKy3Uabt2L8hrciX-YQr2rDHh8cp998X29ZKuOeex/s320/fps_sidescroller02.png" width="320" /></a></div>
<div>
<br /></div>
<br />
<span style="font-family: inherit;"><br /></span>Enjoy!Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-41723761561009072532012-10-05T08:02:00.000+02:002012-10-05T08:14:59.735+02:00Cookbook: Utilizing UDK statesState mechanics in UDK is very useful and makes it easier to organize the code into more readable form and have multiple behaviors ready and running at different times (states). Let's say you want to have your custom camera, that is by default sidescroller 3rd person and can be switched to overhead camera with a key input. Additionally you have a pause mode in your game, where it only slowly rotates around player character...<br />
<br />
It's all easy to achieve with state machine in UDK. Let's see some basic syntax:<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//switches given Object into new state</span></pre>
<pre><span class="lnum"> 2: </span>function GotoState (optional name NewState, ...)</pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="rem">//////////////////////////////////////////////////////////////////////////</span></pre>
<pre><span class="lnum"> 5: </span><span class="rem">//state basic example</span></pre>
<pre><span class="lnum"> 6: </span>state ExploreLevel</pre>
<pre><span class="lnum"> 7: </span>{</pre>
<pre><span class="lnum"> 8: </span> <span class="rem">//these functions are not processed in this state!</span></pre>
<pre><span class="lnum"> 9: </span> ignores SeePlayer, HearNoise, Bump, ...; </pre>
<pre><span class="lnum"> 10: </span> </pre>
<pre><span class="lnum"> 11: </span> <span class="rem">//this function has overriden behaviour in this state</span></pre>
<pre><span class="lnum"> 12: </span> function PlayerMove( <span class="kwrd">float</span> DeltaTime )</pre>
<pre><span class="lnum"> 13: </span> {</pre>
<pre><span class="lnum"> 14: </span> <span class="kwrd">if</span> (explorationKeyPressed)</pre>
<pre><span class="lnum"> 15: </span> {</pre>
<pre><span class="lnum"> 16: </span> BallPuzzlerCamera(PlayerCamera).Explore(DeltaTime);</pre>
<pre><span class="lnum"> 17: </span> <span class="kwrd">else</span> </pre>
<pre><span class="lnum"> 18: </span> {</pre>
<pre><span class="lnum"> 19: </span> <span class="rem">//no key pressed, use the global version of method!</span></pre>
<pre><span class="lnum"> 20: </span> global.PlayerMove(DeltaTime);</pre>
<pre><span class="lnum"> 21: </span> }</pre>
<pre><span class="lnum"> 22: </span> }</pre>
<pre><span class="lnum"> 23: </span> </pre>
<pre><span class="lnum"> 24: </span> Begin: <span class="rem">//do something immediately after switching to this state!</span></pre>
<pre><span class="lnum"> 25: </span> BallPuzzlerCamera(PlayerCamera).SetBallActor(Ball);</pre>
<pre><span class="lnum"> 26: </span>}</pre>
</div>
<br />
Inside state code, you can utilize these useful keywords:<br />
<br />
<ul>
<li><span style="font-family: Courier New, Courier, monospace;">ignores </span>- given methods are not processed while in this state</li>
<li><span style="font-family: Courier New, Courier, monospace;">global.FunctionName</span> - calls default version of method</li>
<li><span style="font-family: Courier New, Courier, monospace;">Begin: </span>- called immediately after switching to this state (you can init some data)</li>
</ul>
<br />
Let's get back to our example. Some simple skeleton of what we want to achieve may look like this:<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> BallPuzzlerCamera extends Camera;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span>...</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span><span class="rem">//state where we act as 3rd person sidescroller camera</span></pre>
<pre><span class="lnum"> 6: </span>state SideScroller</pre>
<pre><span class="lnum"> 7: </span>{</pre>
<pre><span class="lnum"> 8: </span> function UpdateViewTarget(<span class="kwrd">out</span> TViewTarget OutVT, <span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 9: </span> {</pre>
<pre><span class="lnum"> 10: </span> <span class="rem">//sidescroller specific behavior</span></pre>
<pre><span class="lnum"> 11: </span> }</pre>
<pre><span class="lnum"> 12: </span>}</pre>
<pre><span class="lnum"> 13: </span> </pre>
<pre><span class="lnum"> 14: </span><span class="rem">//state where we place camera overhead</span></pre>
<pre><span class="lnum"> 15: </span>state Overhead</pre>
<pre><span class="lnum"> 16: </span>{</pre>
<pre><span class="lnum"> 17: </span> function UpdateViewTarget(<span class="kwrd">out</span> TViewTarget OutVT, <span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 18: </span> {</pre>
<pre><span class="lnum"> 19: </span> <span class="rem">//overhead specific behavior</span></pre>
<pre><span class="lnum"> 20: </span> }</pre>
<pre><span class="lnum"> 21: </span>}</pre>
<pre><span class="lnum"> 22: </span> </pre>
<pre><span class="lnum"> 23: </span><span class="rem">//state where camera is rotation around level</span></pre>
<pre><span class="lnum"> 24: </span>state ExploreLevel</pre>
<pre><span class="lnum"> 25: </span>{</pre>
<pre><span class="lnum"> 26: </span> function UpdateViewTarget(<span class="kwrd">out</span> TViewTarget OutVT, <span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 27: </span> {</pre>
<pre><span class="lnum"> 28: </span> <span class="rem">//level exploration behavior (rotate around level)</span></pre>
<pre><span class="lnum"> 29: </span> }</pre>
<pre><span class="lnum"> 30: </span> </pre>
<pre><span class="lnum"> 31: </span> Begin: <span class="rem">//some init</span></pre>
<pre><span class="lnum"> 32: </span> ResetExploration();</pre>
<pre><span class="lnum"> 33: </span>}</pre>
<pre><span class="lnum"> 34: </span> </pre>
<pre><span class="lnum"> 35: </span><span class="rem">/////////////////////////////////////////////////////////////</span></pre>
<pre><span class="lnum"> 36: </span><span class="rem">//+ in controller class:</span></pre>
<pre><span class="lnum"> 37: </span><span class="rem">/////////////////////////////////////////////////////////////</span></pre>
<pre><span class="lnum"> 38: </span><span class="kwrd">enum</span> E_CameraMode </pre>
<pre><span class="lnum"> 39: </span>{</pre>
<pre><span class="lnum"> 40: </span> E_CM_Sidescroller,</pre>
<pre><span class="lnum"> 41: </span> E_CM_Overhead,</pre>
<pre><span class="lnum"> 42: </span> E_CM_Exploration</pre>
<pre><span class="lnum"> 43: </span>};</pre>
<pre><span class="lnum"> 44: </span> </pre>
<pre><span class="lnum"> 45: </span><span class="kwrd">var</span> <span class="kwrd">byte</span> CurrentCameraMode;</pre>
<pre><span class="lnum"> 46: </span> </pre>
<pre><span class="lnum"> 47: </span>exec function ToggleCameraMode() <span class="rem">//change camera mode with key binding</span></pre>
<pre><span class="lnum"> 48: </span>{</pre>
<pre><span class="lnum"> 49: </span> <span class="kwrd">switch</span> (CurrentCameraMode) <span class="rem">//move to next state!</span></pre>
<pre><span class="lnum"> 50: </span> {</pre>
<pre><span class="lnum"> 51: </span> <span class="kwrd">case</span> E_CM_Sidescroller:</pre>
<pre><span class="lnum"> 52: </span> BallPuzzlerCamera(PlayerCamera).GotoState(<span class="str">'Overhead'</span>); <span class="kwrd">break</span>;</pre>
<pre><span class="lnum"> 53: </span> <span class="kwrd">case</span> E_CM_Overhead:</pre>
<pre><span class="lnum"> 54: </span> BallPuzzlerCamera(PlayerCamera).GotoState(<span class="str">'ExploreLevel'</span>); <span class="kwrd">break</span>;</pre>
<pre><span class="lnum"> 55: </span> <span class="kwrd">case</span> E_CM_Exploration:</pre>
<pre><span class="lnum"> 56: </span> BallPuzzlerCamera(PlayerCamera).GotoState(<span class="str">'SideScroller'</span>); <span class="kwrd">break</span>;</pre>
<pre><span class="lnum"> 57: </span> }</pre>
<pre><span class="lnum"> 58: </span> </pre>
<pre><span class="lnum"> 59: </span> <span class="rem">//move variable to next state</span></pre>
<pre><span class="lnum"> 60: </span> CurrentCameraMode = </pre>
<pre><span class="lnum"> 61: </span> CurrentCameraMode >= E_CM_Exploration ?</pre>
<pre><span class="lnum"> 62: </span> E_CM_Sidescroller : CurrentCameraMode + 1;</pre>
<pre><span class="lnum"> 63: </span>}</pre>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-60891300303549769102012-10-04T09:14:00.003+02:002012-10-04T09:14:29.986+02:00Cookbook: Moving actors in UDK using physics<div style="text-align: justify;">
Imagine you have your ball actor and you want to control it with input keys. You want it to roll in some direction if the key is pressed. Very easy way to achieve this on rigid bodies is by utilizing physics.</div>
<br />
You only need to have your actor <span style="font-family: Courier New, Courier, monospace;">PrimitiveComponent </span>in <span style="font-family: Courier New, Courier, monospace;">PHYS_RigidBody </span>state:<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 2: </span>defaultProperties</pre>
<pre><span class="lnum"> 3: </span>{ </pre>
<pre><span class="lnum"> 4: </span> Begin Object Name=StaticMeshComponent0</pre>
<pre><span class="lnum"> 5: </span> StaticMesh=StaticMesh<span class="str">'BallPuzzlerGame.Actors.PlayerBall'</span></pre>
<pre><span class="lnum"> 6: </span> bNotifyRigidBodyCollision=<span class="kwrd">false</span></pre>
<pre><span class="lnum"> 7: </span> CastShadow=<span class="kwrd">true</span></pre>
<pre><span class="lnum"> 8: </span> BlockRigidBody=<span class="kwrd">true</span></pre>
<pre><span class="lnum"> 9: </span> bCastDynamicShadow=<span class="kwrd">true</span></pre>
<pre><span class="lnum"> 10: </span> HiddenGame=<span class="kwrd">false</span></pre>
<pre><span class="lnum"> 11: </span> LightEnvironment=MyLightEnvironment</pre>
<pre><span class="lnum"> 12: </span> End Object</pre>
<pre><span class="lnum"> 13: </span> Components.Add(StaticMeshComponent0)</pre>
<pre><span class="lnum"> 14: </span> </pre>
<pre><span class="lnum"> 15: </span> Physics=PHYS_RigidBody <span class="rem">//set physics!</span></pre>
<pre><span class="lnum"> 16: </span>}</pre>
</div>
<br />
Then there are multiple possibilities how to move it using impulses/force, etc. (check <span style="font-family: Courier New, Courier, monospace;">PrimitiveComponent </span>documentation for other possibilities):<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>native final function AddImpulse(vector Impulse, ...);</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span>native final function AddForce(vector Force, ...);</pre>
</div>
<br />
And of course, teleporting (useful for resetting to some initial position):<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>native final function SetRBPosition(vector NewPos, ...);</pre>
</div>
<br />
<div style="text-align: justify;">
Let's see it in some example. I'm moving my ball-like actor using <span style="font-family: Courier New, Courier, monospace;">AddImpulse</span>, applying custom gravity using <span style="font-family: Courier New, Courier, monospace;">AddForce </span>and can interact (pick up, move, put down, throw) using <span style="font-family: Courier New, Courier, monospace;">SetRBPosition </span>(overriding original one, while being held) and <span style="font-family: Courier New, Courier, monospace;">AddImpulse </span>when throwing:</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">// Use the player's input to move character</span></pre>
<pre><span class="lnum"> 2: </span>simulated function AddInputForce(<span class="kwrd">float</span> DeltaTime, vector MovementDir)</pre>
<pre><span class="lnum"> 3: </span>{</pre>
<pre><span class="lnum"> 4: </span> StaticMeshComponent.AddImpulse(MovementDir * DeltaTime * Properties.Speed);</pre>
<pre><span class="lnum"> 5: </span>}</pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span><span class="rem">//apply gravity in custom direction</span></pre>
<pre><span class="lnum"> 8: </span>simulated function GravityForce( <span class="kwrd">float</span> DeltaTime )</pre>
<pre><span class="lnum"> 9: </span>{</pre>
<pre><span class="lnum"> 10: </span> StaticMeshComponent.AddForce(GravityVector*Properties.Gravity);</pre>
<pre><span class="lnum"> 11: </span>}</pre>
<pre><span class="lnum"> 12: </span> </pre>
<pre><span class="lnum"> 13: </span><span class="rem">//handle being locked</span></pre>
<pre><span class="lnum"> 14: </span>simulated <span class="kwrd">event</span> Tick(Float DT)</pre>
<pre><span class="lnum"> 15: </span>{</pre>
<pre><span class="lnum"> 16: </span> <span class="rem">//we are locked, follow owner, override default behaviour</span></pre>
<pre><span class="lnum"> 17: </span> <span class="kwrd">if</span> (lockInstigator != none)</pre>
<pre><span class="lnum"> 18: </span> {</pre>
<pre><span class="lnum"> 19: </span> StaticMeshComponent.SetRBPosition(lockInstigator.Location + lockTranslation);</pre>
<pre><span class="lnum"> 20: </span> }</pre>
<pre><span class="lnum"> 21: </span> <span class="kwrd">else</span></pre>
<pre><span class="lnum"> 22: </span> {</pre>
<pre><span class="lnum"> 23: </span> super.Tick(DT); <span class="rem">//basic behavior</span></pre>
<pre><span class="lnum"> 24: </span> }</pre>
<pre><span class="lnum"> 25: </span>}</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here is a video showing all this in motion:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/jkRKeIxIhOo?feature=player_embedded' frameborder='0'></iframe></div>
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com4tag:blogger.com,1999:blog-6001082585535661666.post-43542969556054582552012-10-03T23:31:00.001+02:002012-10-03T23:31:41.327+02:00Cookbook: UDK set of objects instead of a Pawn<div style="text-align: justify;">
Normally, UDK is mainly a framework for first/third person shooter games. Many things are hardcoded, like necessity to have a Pawn as you main character (or references to UT3 in DefaultEngine.ini). For smaller (indie) projects that is many times not desired. What if you want to be able to control a simple KActor or some set of objects (like chess pieces)? That is not a problem!<br />
<br />
insert instances of desired objects into scene (I'm controlling one actor):<br />
<br />
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWwhyphenhyphenWl3lOK0adVjcL5SDQ3wCxlj5gKBs6qYOLL0V2g12PBS5XI3qEsF8dpNF5mYZKtLx3W5cA57UkF2nuTFq9Euu6yfWb8V0jkv_PI0jCksEaGnwCmmJN4ZJlWGj8DU9Z5a0sFElXG4fl/s1600/actor_instead_of_pawn.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWwhyphenhyphenWl3lOK0adVjcL5SDQ3wCxlj5gKBs6qYOLL0V2g12PBS5XI3qEsF8dpNF5mYZKtLx3W5cA57UkF2nuTFq9Euu6yfWb8V0jkv_PI0jCksEaGnwCmmJN4ZJlWGj8DU9Z5a0sFElXG4fl/s320/actor_instead_of_pawn.png" width="320" /></a></div>
<br /></div>
<div>
<br /></div>
collect references to your objects in some early phase:<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">var</span> MyActorClass MyActor</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span>simulated <span class="kwrd">event</span> PostBeginPlay()</pre>
<pre><span class="lnum"> 4: </span>{</pre>
<pre><span class="lnum"> 5: </span> super.PostBeginPlay(); <span class="rem">//call parent</span></pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span> <span class="rem">//iterate through all actors of given class and store them!</span></pre>
<pre><span class="lnum"> 8: </span> <span class="kwrd">foreach</span> WorldInfo.DynamicActors(<span class="kwrd">class</span><span class="str">'MyActorClass'</span>, MyActor)</pre>
<pre><span class="lnum"> 9: </span> {</pre>
<pre><span class="lnum"> 10: </span> <span class="rem">//some additional init?</span></pre>
<pre><span class="lnum"> 11: </span> Init();</pre>
<pre><span class="lnum"> 12: </span> <span class="kwrd">break</span>; <span class="rem">//if interested only in first one</span></pre>
<pre><span class="lnum"> 13: </span> }</pre>
<pre><span class="lnum"> 14: </span>}</pre>
</div>
<br />
override Pawn dependent behavior in your custom classes to work with your actors (example from custom 3rd person camera):<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> MyCamera extends Camera;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">//override, use your actor as the point of interest for camera</span></pre>
<pre><span class="lnum"> 4: </span>function UpdateViewTarget(<span class="kwrd">out</span> TViewTarget OutVT, <span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 5: </span>{</pre>
<pre><span class="lnum"> 6: </span> super.UpdateViewTarget(OutVT,DeltaTime);</pre>
<pre><span class="lnum"> 7: </span> </pre>
<pre><span class="lnum"> 8: </span> <span class="rem">//add some offset to the target's for 3rd person camera</span></pre>
<pre><span class="lnum"> 9: </span> OutVT.POV.Location = MyActor.Location + Properties.CamOffset;</pre>
<pre><span class="lnum"> 10: </span> </pre>
<pre><span class="lnum"> 11: </span> <span class="rem">// Make the camera point towards the target's location</span></pre>
<pre><span class="lnum"> 12: </span> OutVT.POV.Rotation = Rotator(MyActor.Location - OutVT.POV.Location);</pre>
<pre><span class="lnum"> 13: </span>}</pre>
</div>
<br /></div>
<br />
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com1tag:blogger.com,1999:blog-6001082585535661666.post-45879461689525310202012-10-03T08:35:00.000+02:002012-10-03T10:52:02.080+02:00Cookbook: UDK timers<div style="text-align: justify;">
Timers in UDK are very useful if you want to call a postponed method (e.g. in 5seconds) or call something regularly (e.g. doing some statistics update each 10 seconds).</div>
<br />
Syntax is very simple:<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//set timer: (time to trigger,</span></pre>
<pre><span class="lnum"> 2: </span><span class="rem">// true - repeated/false - once only,</span></pre>
<pre><span class="lnum"> 3: </span><span class="rem">// method name to call in '')</span></pre>
<pre><span class="lnum"> 4: </span>SetTimer(2.0,,<span class="str">'MyTimerName'</span>);</pre>
<pre><span class="lnum"> 5: </span> </pre>
<pre><span class="lnum"> 6: </span><span class="rem">//stops timer execution</span></pre>
<pre><span class="lnum"> 7: </span>ClearTimer(<span class="str">'MyTimerName'</span>);</pre>
</div>
<br />
<div style="text-align: justify;">
Let's take a look at a simple example. Let's say we want to have a button that resets itself after given amount of time and additionally updates HUD with time left regularly (for HUD messaging see previous tutorial <a href="http://gravityspeedrun.blogspot.sk/2012/10/cookbook-udk-cascading-hud-messages.html">Cookbook: UDK cascading HUD messages</a>, for kismet events see previous tutorial <a href="http://gravityspeedrun.blogspot.sk/2012/10/cookbook-triggering-events-uscript.html">Cookbook: Triggering events, uscript -> kismet</a> ).</div>
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> ButtonActorTimer extends ButtonActor;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">/** time for button to stay activated (then reset) */</span></pre>
<pre><span class="lnum"> 4: </span><span class="kwrd">var</span>(Game) <span class="kwrd">float</span> fTimeToReset;</pre>
<pre><span class="lnum"> 5: </span> </pre>
<pre><span class="lnum"> 6: </span><span class="rem">/** time for tick (display message) */</span></pre>
<pre><span class="lnum"> 7: </span><span class="kwrd">var</span>(Game) <span class="kwrd">float</span> fTimeToTick;</pre>
<pre><span class="lnum"> 8: </span> </pre>
<pre><span class="lnum"> 9: </span><span class="kwrd">var</span> <span class="kwrd">float</span> fTimeLeft;</pre>
<pre><span class="lnum"> 10: </span> </pre>
<pre><span class="lnum"> 11: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 12: </span>function TimeOut()</pre>
<pre><span class="lnum"> 13: </span>{</pre>
<pre><span class="lnum"> 14: </span> <span class="rem">//trigger event with myself as instigator</span></pre>
<pre><span class="lnum"> 15: </span> self.TriggerEventClass(<span class="kwrd">class</span><span class="str">'SeqEvent_ButtonReset'</span>, self);</pre>
<pre><span class="lnum"> 16: </span> Reset();</pre>
<pre><span class="lnum"> 17: </span>}</pre>
<pre><span class="lnum"> 18: </span> </pre>
<pre><span class="lnum"> 19: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 20: </span>function TimeTick()</pre>
<pre><span class="lnum"> 21: </span>{</pre>
<pre><span class="lnum"> 22: </span> fTimeLeft -= fTimeToTick; <span class="rem">//update time</span></pre>
<pre><span class="lnum"> 23: </span> Controller.StringToHUD(fTimeLeft$<span class="str">"..."</span>); <span class="rem">//show HUD message</span></pre>
<pre><span class="lnum"> 24: </span>}</pre>
<pre><span class="lnum"> 25: </span> </pre>
<pre><span class="lnum"> 26: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 27: </span>function Set()</pre>
<pre><span class="lnum"> 28: </span>{</pre>
<pre><span class="lnum"> 29: </span> SetTimer(fTimeToReset,,<span class="str">'TimeOut'</span>); <span class="rem">//set new reset timer (called once)</span></pre>
<pre><span class="lnum"> 30: </span> fTimeLeft = fTimeToReset;</pre>
<pre><span class="lnum"> 31: </span> SetTimer(fTimeToTick,<span class="kwrd">true</span>,<span class="str">'TimeTick'</span>); <span class="rem">//ticking message (repeatedly)</span></pre>
<pre><span class="lnum"> 32: </span>}</pre>
<pre><span class="lnum"> 33: </span> </pre>
<pre><span class="lnum"> 34: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 35: </span>function Reset()</pre>
<pre><span class="lnum"> 36: </span>{</pre>
<pre><span class="lnum"> 37: </span> ClearTimer(<span class="str">'TimeOut'</span>); <span class="rem">//reset timer!</span></pre>
<pre><span class="lnum"> 38: </span> ClearTimer(<span class="str">'TimeTick'</span>);</pre>
<pre><span class="lnum"> 39: </span>}</pre>
</div>
<br />
<div style="text-align: justify;">
Button has two independent timers, one for reset (re-enable button, and send reset event to kismet) after time is up (door closes, etc.), second timer is for HUD update and sends time left message onto HUD.</div>
<br />
Here is some ingame screenshot:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ5xUGXQ1xGBtbKzrMlnwjM6EBUU5ICzvTCPbPeZ_alet8WwKlBqKQbOBubwafhwTfYNj6rr_XEj4KybO2GPK3J7r5D_1Q2UA9OaPNTRzYE4Xrx-ptG4SzT7K_r-Ktd-VeWji_LCje7HB5/s1600/button_timer.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ5xUGXQ1xGBtbKzrMlnwjM6EBUU5ICzvTCPbPeZ_alet8WwKlBqKQbOBubwafhwTfYNj6rr_XEj4KybO2GPK3J7r5D_1Q2UA9OaPNTRzYE4Xrx-ptG4SzT7K_r-Ktd-VeWji_LCje7HB5/s320/button_timer.png" width="320" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-28786141140694750812012-10-02T16:27:00.000+02:002012-10-02T16:27:16.932+02:00Cookbook: UDK cascading HUD messages<div style="text-align: justify;">
Many games have some messaging system on their HUDs (player picked up some power-up, have taken some damage, timer is ticking away, etc.). Using just the simple extension of HUD class, you can achieve similar results.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
We'll use a simple structure to represent our message:</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//message struct define</span></pre>
<pre><span class="lnum"> 2: </span><span class="kwrd">struct</span> HUDMessage</pre>
<pre><span class="lnum"> 3: </span>{</pre>
<pre><span class="lnum"> 4: </span> <span class="kwrd">var</span> <span class="kwrd">string</span> sMessage;</pre>
<pre><span class="lnum"> 5: </span> <span class="kwrd">var</span> <span class="kwrd">float</span> fMessageTimer;</pre>
<pre><span class="lnum"> 6: </span>};</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Simple method to display string on HUD (based on great <a href="http://labs.vectorform.com/2011/11/creating-a-side-scrolling-game-with-udk/">vectorlab tutorial</a>):<br />
<br />
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 2: </span> function DrawString(<span class="kwrd">string</span> text, <span class="kwrd">int</span> X, <span class="kwrd">int</span> Y, <span class="kwrd">int</span> R, <span class="kwrd">int</span> G, <span class="kwrd">int</span> B, <span class="kwrd">int</span> A)</pre>
<pre><span class="lnum"> 3: </span> {</pre>
<pre><span class="lnum"> 4: </span> Canvas.SetPos(X, Y);</pre>
<pre><span class="lnum"> 5: </span> Canvas.SetDrawColor(R, G, B, A);</pre>
<pre><span class="lnum"> 6: </span> Canvas.Font = <span class="kwrd">class</span><span class="str">'Engine'</span>.<span class="kwrd">static</span>.GetMediumFont(); </pre>
<pre><span class="lnum"> 7: </span> Canvas.DrawText(text);</pre>
<pre><span class="lnum"> 8: </span> }</pre>
</div>
<br />
All messages are stored in a simple dynamic array and updated/displayed/removed each frame:</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">var</span> array<HUDMessage> aMessages;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">//public method to be called from anywhere in game (your actors, etc.)</span></pre>
<pre><span class="lnum"> 4: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 5: </span>function StringToHUD(<span class="kwrd">string</span> message, <span class="kwrd">float</span> timer = 0)</pre>
<pre><span class="lnum"> 6: </span>{</pre>
<pre><span class="lnum"> 7: </span> local HUDMessage newMessage;</pre>
<pre><span class="lnum"> 8: </span> </pre>
<pre><span class="lnum"> 9: </span> newMessage.sMessage = message;</pre>
<pre><span class="lnum"> 10: </span> newMessage.fMessageTimer = -timer; <span class="rem">//make it appear longer, optional</span></pre>
<pre><span class="lnum"> 11: </span> </pre>
<pre><span class="lnum"> 12: </span> aMessages.InsertItem(0,newMessage); <span class="rem">//insert at the beginning!</span></pre>
<pre><span class="lnum"> 13: </span>}</pre>
<pre><span class="lnum"> 14: </span> </pre>
<pre><span class="lnum"> 15: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 16: </span>simulated <span class="kwrd">event</span> Tick(<span class="kwrd">float</span> DeltaTime)</pre>
<pre><span class="lnum"> 17: </span>{</pre>
<pre><span class="lnum"> 18: </span> local <span class="kwrd">int</span> i;</pre>
<pre><span class="lnum"> 19: </span> </pre>
<pre><span class="lnum"> 20: </span> <span class="rem">//update message array</span></pre>
<pre><span class="lnum"> 21: </span> <span class="kwrd">for</span> (i = 0; i < aMessages.length; ++i)</pre>
<pre><span class="lnum"> 22: </span> {</pre>
<pre><span class="lnum"> 23: </span> aMessages[i].fMessageTimer += DeltaTime;</pre>
<pre><span class="lnum"> 24: </span> }</pre>
<pre><span class="lnum"> 25: </span>}</pre>
<pre><span class="lnum"> 26: </span> </pre>
<pre><span class="lnum"> 27: </span><span class="rem">//draw routine to display cascaded messages</span></pre>
<pre><span class="lnum"> 28: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 29: </span>function DrawCustomMessage()</pre>
<pre><span class="lnum"> 30: </span>{</pre>
<pre><span class="lnum"> 31: </span> local HUDMessage message;</pre>
<pre><span class="lnum"> 32: </span> local offsetY = 200;</pre>
<pre><span class="lnum"> 33: </span> </pre>
<pre><span class="lnum"> 34: </span> <span class="kwrd">foreach</span> aMessages(message) <span class="rem">//display all messages</span></pre>
<pre><span class="lnum"> 35: </span> {</pre>
<pre><span class="lnum"> 36: </span> <span class="rem">//message is still to be displayed</span></pre>
<pre><span class="lnum"> 37: </span> <span class="kwrd">if</span> (message.fMessageTimer < 2.0f)</pre>
<pre><span class="lnum"> 38: </span> { </pre>
<pre><span class="lnum"> 39: </span>DrawString(message.sMessage,0,offsetY,255,255,255,255,<span class="kwrd">true</span>);</pre>
<pre><span class="lnum"> 40: </span> offsetY += 20; <span class="rem">//update next message position</span></pre>
<pre><span class="lnum"> 41: </span> }</pre>
<pre><span class="lnum"> 42: </span> <span class="kwrd">else</span> <span class="rem">//expired, remove</span></pre>
<pre><span class="lnum"> 43: </span> {</pre>
<pre><span class="lnum"> 44: </span> aMessages.RemoveItem(message);</pre>
<pre><span class="lnum"> 45: </span> }</pre>
<pre><span class="lnum"> 46: </span> }</pre>
<pre><span class="lnum"> 47:</span></pre>
<pre><span class="lnum"> 48: </span>}</pre>
<pre><span class="lnum"> 49: </span> </pre>
<pre><span class="lnum"> 50: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 51: </span>function DrawHUD()</pre>
<pre><span class="lnum"> 52: </span>{</pre>
<pre><span class="lnum"> 53: </span> super.DrawHUD(); <span class="rem">//don't forget to call parent method!</span></pre>
<pre><span class="lnum"> 54: </span> </pre>
<pre><span class="lnum"> 55: </span> DrawCustomMessage(); <span class="rem">//our messaging routine</span></pre>
<pre><span class="lnum"> 56: </span> }</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
And here is an example screenshot directly from game:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPdwgjtv0_p6OyoD516ZNIWK-7-KS5SHZZhVjFk5_OPhS7EDnussMqOEhjO7smymZRL7G1Fq0SxoTmS21ABvS2AdkCU355vCBXW4oo6ZgLy9L5lMzBttLd9KeAmNpYN_xPo79jGqPc_S6F/s1600/hud_messages.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="214" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPdwgjtv0_p6OyoD516ZNIWK-7-KS5SHZZhVjFk5_OPhS7EDnussMqOEhjO7smymZRL7G1Fq0SxoTmS21ABvS2AdkCU355vCBXW4oo6ZgLy9L5lMzBttLd9KeAmNpYN_xPo79jGqPc_S6F/s320/hud_messages.png" width="320" /></a></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-24600506429018747322012-10-02T08:47:00.000+02:002012-10-02T11:39:37.540+02:00Cookbook: UDK artist editable properties<div style="text-align: justify;">
Sooner or late in your development you'll come into phase when you have some game skeleton with a lot of parameters (camera, health, etc.). But how to tweak them without the necessity to update unrealscript (<span style="font-family: Courier New, Courier, monospace;">defaultproperties</span>) and recompiling?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
There are two approaches you can use. Let's take a closer look:</div>
<div style="text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Instanced objects/actors</h3>
<div style="text-align: justify;">
Each of your actors (buttons, movable/breakable objects, custom lights) will probably need some variables that are preferably tweakable by artist. Additionally each of there instances needs possibility to have differing values of parameters (imagine your <span style="font-family: Courier New, Courier, monospace;">ButtonActor </span>with blue light and specific mesh vs other instance of <span style="font-family: Courier New, Courier, monospace;">ButtonActor </span>with no light and different mesh).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This is easily achievable using named variables in unrealscript, syntax is really simple:</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> ButtonActor extends Actor</pre>
<pre><span class="lnum"> 2: </span> ClassGroup(BallPuzzler)</pre>
<pre><span class="lnum"> 3: </span> placeable;</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span><span class="rem">// /** */ specifies comment visible for artist in editor</span></pre>
<pre><span class="lnum"> 6: </span><span class="rem">/** enables actor movement upon activation */</span></pre>
<pre><span class="lnum"> 7: </span><span class="rem">//(Game) specifies category for parameter in unreal editor</span></pre>
<pre><span class="lnum"> 8: </span><span class="kwrd">var</span>(Game) <span class="kwrd">bool</span> bMove;</pre>
<pre><span class="lnum"> 9: </span> </pre>
<pre><span class="lnum"> 10: </span><span class="rem">/** movement offset from base position */</span></pre>
<pre><span class="lnum"> 11: </span><span class="kwrd">var</span>(Game) vector vMoveOffset;</pre>
<pre><span class="lnum"> 12: </span> </pre>
<pre><span class="lnum"> 13: </span><span class="rem">/** sound to play upon activation */</span></pre>
<pre><span class="lnum"> 14: </span><span class="kwrd">var</span> (Game) SoundCue activationSound;</pre>
<pre><span class="lnum"> 15: </span> </pre>
<pre><span class="lnum"> 16: </span><span class="kwrd">var</span>(Light) <span class="kwrd">const</span> LightComponent LightComponent;</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This setup results in parameters being categorized in unreal editor into specified groups (<span style="font-family: Courier New, Courier, monospace;">F4 </span>on selected actor):</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq1BfdcPwVGdS9cwnB-2NXaFIbWT4TYvm7F4aUxFBDvPdKKE4ZZ-860AIv4gY7wXPJucsFgVTA2ku0DILh_H9jLdlEDHnqhlUNG5Kr5Nu2LgXUVCSU_J9CpZ6uh579Hge7MkC4afoynP07/s1600/actor_properties.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq1BfdcPwVGdS9cwnB-2NXaFIbWT4TYvm7F4aUxFBDvPdKKE4ZZ-860AIv4gY7wXPJucsFgVTA2ku0DILh_H9jLdlEDHnqhlUNG5Kr5Nu2LgXUVCSU_J9CpZ6uh579Hge7MkC4afoynP07/s320/actor_properties.png" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I recommend to create archetype also for instanced objects to create subtypes (for example blue button, red button, healing button) and then use them to create instances (and edit few parameters per instance if necessary).<br />
<br /></div>
<h3 style="text-align: justify;">
Not placeable objects</h3>
<div style="text-align: justify;">
<br />
Ok, above mentioned steps work fine for instanced object that are being placed into game level. But what about objects without physical representation in editor (e.g. camera, controller, HUD, etc.)? Here we can create specific Properties object, that can be archetyped and it's parameters updated in content browser.</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> BallPuzzlerProperties extends Object</pre>
<pre><span class="lnum"> 2: </span> HideCategories(Object);</pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span><span class="rem">/** min distance from camera */</span></pre>
<pre><span class="lnum"> 5: </span><span class="kwrd">var</span>(Camera) vector CamOffsetNear;</pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span><span class="rem">/** max distance for camera */</span></pre>
<pre><span class="lnum"> 8: </span><span class="kwrd">var</span>(Camera) vector CamOffsetFar;</pre>
<pre><span class="lnum"> 9: </span> </pre>
<pre><span class="lnum"> 10: </span><span class="rem">/** focus inner radius when in exploration mode */</span></pre>
<pre><span class="lnum"> 11: </span><span class="kwrd">var</span>(PostProcess) <span class="kwrd">float</span> fFocusRadiusExploration;</pre>
<pre><span class="lnum"> 12: </span> </pre>
<pre><span class="lnum"> 13: </span><span class="rem">/** movement speed */</span></pre>
<pre><span class="lnum"> 14: </span><span class="kwrd">var</span>(Movement) <span class="kwrd">float</span> Speed;</pre>
<pre><span class="lnum"> 15: </span> </pre>
<pre><span class="lnum"> 16: </span><span class="rem">/** jump force */</span></pre>
<pre><span class="lnum"> 17: </span><span class="kwrd">var</span>(Movement) <span class="kwrd">float</span> Jump;</pre>
<pre><span class="lnum"> 18: </span> </pre>
<pre><span class="lnum"> 19: </span><span class="rem">/** how much energy to drain at once */</span></pre>
<pre><span class="lnum"> 20: </span><span class="kwrd">var</span>(Other) <span class="kwrd">float</span> EnergyDrainAmount;</pre>
<pre><span class="lnum"> 21: </span> </pre>
<pre><span class="lnum"> 22: </span><span class="rem">/** distance to moveable object allowing its pickup */</span></pre>
<pre><span class="lnum"> 23: </span><span class="kwrd">var</span>(Manipulate) <span class="kwrd">float</span> PickupDistance;</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Creating and archetype is really simple. Open your Content Browser, click on Actor classes tab, uncheck all checkboxes (as this is not placeable, nor actor) and find your properties object. Right click, create an archetype, specify your package and some cool name (like Properties ;) ) and there you go! From now on, all your global parameters are accessible via properties of this archetype (<span style="font-family: Courier New, Courier, monospace;">F4</span>)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtc-opEEFqbdijqc2MV8xpeYLgUCf8KWdFTM0kpwIG_4SRpKffDAI-I71FUc2397W8HG0idjcfYuAdWMmJq_wDPUoyi1avtUZOoXS4VBCP2M1Y8QTgF2-OrurW_q8Ihwt5fVxqbrmR0emt/s1600/create_archetype.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtc-opEEFqbdijqc2MV8xpeYLgUCf8KWdFTM0kpwIG_4SRpKffDAI-I71FUc2397W8HG0idjcfYuAdWMmJq_wDPUoyi1avtUZOoXS4VBCP2M1Y8QTgF2-OrurW_q8Ihwt5fVxqbrmR0emt/s320/create_archetype.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoWGEAsYUSf32eNvNb4DPAsyasrSDI3nYsC5_rGxH41CL2qw8QW_Du1mAVlz3EFIZituoMVafKGbzOLdkCuI9suGmb6e_mg6A6rNTEugsr2i3AzhKhDN5pnRnZIfEwMQGfvj5u1Py3KHjj/s1600/global_properties.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="187" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoWGEAsYUSf32eNvNb4DPAsyasrSDI3nYsC5_rGxH41CL2qw8QW_Du1mAVlz3EFIZituoMVafKGbzOLdkCuI9suGmb6e_mg6A6rNTEugsr2i3AzhKhDN5pnRnZIfEwMQGfvj5u1Py3KHjj/s320/global_properties.png" width="320" /></a></div>
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To have an access to properties archetype in unrealscript, just reference it in variables and default properties. After that you can access it as any default structure.</div>
<div style="text-align: justify;">
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> BallPuzzlerCamera extends Camera;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="kwrd">var</span> <span class="kwrd">const</span> archetype BallPuzzlerProperties Properties; <span class="rem">//declare variable</span></pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span>...</pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 8: </span>function ComputeCameraRotation(<span class="kwrd">float</span> DT)</pre>
<pre><span class="lnum"> 9: </span>{</pre>
<pre><span class="lnum"> 10: </span> local <span class="kwrd">float</span> partAngle;</pre>
<pre><span class="lnum"> 11: </span> </pre>
<pre><span class="lnum"> 12: </span> <span class="rem">//use it!</span></pre>
<pre><span class="lnum"> 13: </span> partAngle = Properties.CamRotDelta * DT;</pre>
<pre><span class="lnum"> 14: </span> </pre>
<pre><span class="lnum"> 15: </span>...</pre>
<pre><span class="lnum"> 16: </span> </pre>
<pre><span class="lnum"> 17: </span>defaultproperties</pre>
<pre><span class="lnum"> 18: </span>{</pre>
<pre><span class="lnum"> 19: </span> <span class="rem">//define it as external from package</span></pre>
<pre><span class="lnum"> 20: </span> Properties=BallPuzzlerProperties<span class="str">'BallPuzzlerGame.Archetypes.Properties'</span></pre>
<pre><span class="lnum"> 21: </span>}</pre>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-21471808621278497132012-10-01T10:21:00.001+02:002012-10-09T16:29:59.507+02:00Cookbook: Triggering events, uscript -> kismet<div style="text-align: justify;">
Imagine you want to have a custom unrealscript actor (e.g. button). Obviously you want that button to introduce some interactivity to your scene/level. Let's say you want it to trigger some event for kismet (universal event that you want to be able to hook to any action available - play a matinee movie, toggle light, etc.)</div>
<br />
What do we need?<br />
<br />
<b>
1. create simple Seq_Event</b><br />
<div>
<br />
<div style="text-align: justify;">
All we need is a super simple event without any internal functionality. It's a good habit to organize it into some category (<span style="font-family: Courier New, Courier, monospace;">ObjCategory</span>).</div>
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> SeqEvent_ButtonSet extends SequenceEvent;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span>defaultproperties</pre>
<pre><span class="lnum"> 4: </span>{</pre>
<pre><span class="lnum"> 5: </span> ObjName=<span class="str">"ButtonSet"</span> <span class="rem">//kismet event name</span></pre>
<pre><span class="lnum"> 6: </span> ObjCategory=<span class="str">"MyGame"</span> <span class="rem">//kismet event menu category</span></pre>
<pre><span class="lnum"> 7: </span> bPlayerOnly = <span class="kwrd">false</span> <span class="rem">//only pawn based actor can trigger?</span></pre>
<pre><span class="lnum"> 8: </span>}</pre>
<pre></pre>
</div>
<div>
<br /></div>
<b>
2. trigger it from script</b><br />
<br />
<div style="text-align: justify;">
In our ButtonActor we need to trigger the given event somewhere. In this example it is triggered whenever touch event occurs (it'd be better to have some checks whether it's triggered by our pawn, some specific actor, etc.). To make our life easier, event is added to <span style="font-family: Courier New, Courier, monospace;">SupportedEvents </span>in <span style="font-family: Courier New, Courier, monospace;">defaultproperties</span> (this way it'll show in kismet right click menu when buttonActor is selected in scene).</div>
<br />
<div>
<br /></div>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> ButtonActor extends Actor</pre>
<pre><span class="lnum"> 2: </span> ClassGroup(MyGame) <span class="rem">//group for actor classes menu (content browser)</span></pre>
<pre><span class="lnum"> 3: </span> placeable;</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span>...</pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span><span class="rem">//========================================================================</span></pre>
<pre><span class="lnum"> 8: </span><span class="kwrd">event</span> Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal )</pre>
<pre><span class="lnum"> 9: </span>{</pre>
<pre><span class="lnum"> 10: </span> <span class="rem">//trigger event with myself as instigator</span></pre>
<pre><span class="lnum"> 11: </span> TriggerEventClass(<span class="kwrd">class</span><span class="str">'SeqEvent_ButtonSet'</span>, self);</pre>
<pre><span class="lnum"> 12: </span>}</pre>
<pre><span class="lnum"> 13: </span> </pre>
<pre><span class="lnum"> 14: </span>...</pre>
<pre><span class="lnum"> 15: </span> </pre>
<pre><span class="lnum"> 16: </span>defaultproperties</pre>
<pre><span class="lnum"> 17: </span>{ </pre>
<pre><span class="lnum"> 18: </span> SupportedEvents.Add(<span class="kwrd">class</span><span class="str">'SeqEvent_ButtonSet'</span>) <span class="rem">//to see it in kismet (selected actor, add event using actor...)</span></pre>
<pre><span class="lnum"> 19: </span>}</pre>
</div>
<div>
<br /></div>
<b>
3. connect it to some kismet action</b><br />
<br />
<div style="text-align: justify;">
Here we need to insert an instance of our button into scene and (with button selected) in kismet right click Add event using actor -> you'll see our new event in submenu, add it! After that, all that is left is to connect it to whatever action you want. Example image shows button that plays open the door animation and turns matching color lights connected to door and button off.</div>
<br />
<b><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYYV-wFPALCXzjO1T9PtdF_maCgmhJfwIwNZAbwonUGyHcfzxv8qDqTs6shKOzBqCsqtGA2x4g8tJo_sBIJMQMVmawS35X5B1gIUevYITK6glV2FUteoXzb2KoD5UnrdyP2wcgu-SD7OdX/s1600/kismet_button_seqevent.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="153" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYYV-wFPALCXzjO1T9PtdF_maCgmhJfwIwNZAbwonUGyHcfzxv8qDqTs6shKOzBqCsqtGA2x4g8tJo_sBIJMQMVmawS35X5B1gIUevYITK6glV2FUteoXzb2KoD5UnrdyP2wcgu-SD7OdX/s320/kismet_button_seqevent.png" width="320" /></a></div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com5tag:blogger.com,1999:blog-6001082585535661666.post-91963784471286698002012-09-28T09:29:00.001+02:002012-10-01T15:49:40.052+02:00Design ideas<div style="text-align: justify;">
Ok, so I have a sandbox testing playground of a game. But what to do with it next? Here are some of my ideas.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWybV6wg3D32Q762-LsywS_h6eIUFHd9om54GZW0JRsCwu17ht1y3bUyVNe9qRCMgPnA4yW1XJ3RATJecOiEStHa2wUODLBpHNBdqF8yTM3Fx0F0MzYPVOLG7kT1JKgQU1Sviz9QADcTsT/s1600/topdown_maze.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWybV6wg3D32Q762-LsywS_h6eIUFHd9om54GZW0JRsCwu17ht1y3bUyVNe9qRCMgPnA4yW1XJ3RATJecOiEStHa2wUODLBpHNBdqF8yTM3Fx0F0MzYPVOLG7kT1JKgQU1Sviz9QADcTsT/s320/topdown_maze.png" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Settings:</h3>
<div>
<ul>
<li style="text-align: justify;">post-apocalyptic settings</li>
<ul>
<li style="text-align: justify;">broken technology everywhere</li>
<li style="text-align: justify;">placement in space (old space station? stars visible through windows?)</li>
<ul>
<li style="text-align: justify;">still partially functional</li>
<li style="text-align: justify;">main goal is to repair station (collecting necessary spare parts while moving through levels)</li>
<li style="text-align: justify;">levels are not fully accessible at start, you need to push correct buttons, levers to open some previously inaccessible corridors</li>
</ul>
<li style="text-align: justify;">main character is a small robot (or robots?)</li>
<ul>
<li style="text-align: justify;">body is basically a rotating sphere with some levitating head/arms</li>
<li style="text-align: justify;">cute stylisation as in contrast to bleak world</li>
</ul>
</ul>
</ul>
</div>
<h3>
Gameplay:</h3>
<div>
<ul>
<li>navigate through maze of corridors, get to the exit, fix given engine part, etc.</li>
<li>use abilities, solve puzzles to unlock inaccessible level parts</li>
<li>interactive environment: buttons, levers, inverse gravity fields, doors, elevators</li>
<li>with level progress growing set of abilities (pushing buttons, controlling gravity, controlling elevators, moving objects, etc.)
</li>
<li>isometric top down camera?</li>
<li>co-op gameplay:</li>
<ul>
<li>two robots with differing set of abilities</li>
<ul>
<li>one can push buttons (opens door for other robot)</li>
<li>other robot can jump, move object (cover the hole in ground for other robot to cross)</li>
<li>...</li>
</ul>
<li>need to cooperate to unlock the path for other robot</li>
<li>good for singleplayer (switching between robots) as well as for multiplayer (each player one robot)</li>
</ul>
</ul>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-40906115352997654352012-09-27T14:16:00.000+02:002012-10-01T15:50:09.398+02:00Cookbook: UDK simple data save/load from diskHave you ever wondered how to store simple data (save game) somewhere on the disk with UDK?<br />
<br />
Simplest way that I discovered is usage of existing config system API. Let's present its usage on simple temporary leaderboard system that I use:<br />
<br />
<ul>
<li>create a new config file (for example <span style="font-family: Courier New, Courier, monospace;">MyLevelLeaderboard.ini</span>)</li>
<li>create script file that specifies its content</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>Class LevelLeaderboard extends Object</pre>
<pre><span class="lnum"> 2: </span> PerObjectConfig</pre>
<pre><span class="lnum"> 3: </span> Config(MyLevelLeaderboard);</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span><span class="kwrd">var</span> config <span class="kwrd">float</span> bestTime; <span class="rem">//specify variables</span></pre>
<pre><span class="lnum"> 6: </span><span class="kwrd">var</span> config <span class="kwrd">int</span> bestScore;</pre>
<pre><span class="lnum"> 7: </span><span class="kwrd">var</span> config <span class="kwrd">int</span> bestSteps;</pre>
</div>
<div>
<ul>
<li>access and edit data via script</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>local LevelLeaderboard LL;</pre>
<pre><span class="lnum"> 2: </span> </pre>
<pre><span class="lnum"> 3: </span><span class="rem">//load old bests (for current level), creates file if not existing</span></pre>
<pre><span class="lnum"> 4: </span><span class="rem">//second parameter specifies subsection name in ini file</span></pre>
<pre><span class="lnum"> 5: </span>LL = <span class="kwrd">new</span>(None,WorldInfo.GetMapName(<span class="kwrd">false</span>)) <span class="kwrd">class</span><span class="str">'LevelLeaderboard'</span>;</pre>
<pre><span class="lnum"> 6: </span> </pre>
<pre><span class="lnum"> 7: </span><span class="rem">//update values</span></pre>
<pre><span class="lnum"> 8: </span>LL.bestTime = FMin(totalTime,LL.bestTime);</pre>
<pre><span class="lnum"> 9: </span>LL.bestScore = FMax(totalScore,LL.bestScore);</pre>
<pre><span class="lnum"> 10: </span>LL.bestSteps = FMin(totalSteps,LL.bestSteps);</pre>
<pre><span class="lnum"> 11: </span>LL.SaveConfig(); <span class="rem">//save changes</span></pre>
</div>
<br />
<br />
<ul>
<li>resulting
<span style="font-family: 'Courier New', Courier, monospace;">MyLevelLeaderboard.ini</span> file looks like this</li>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>[testlevel1 LevelLeaderboard]</pre>
<pre><span class="lnum"> 2: </span>bestTime=73.390839</pre>
<pre><span class="lnum"> 3: </span>bestScore=4600</pre>
<pre><span class="lnum"> 4: </span>bestSteps=218</pre>
<pre><span class="lnum"> 5: </span> </pre>
<pre><span class="lnum"> 6: </span>[testlevelpuzzles LevelLeaderboard]</pre>
<pre><span class="lnum"> 7: </span>bestTime=2.615733</pre>
<pre><span class="lnum"> 8: </span>bestScore=100</pre>
<pre><span class="lnum"> 9: </span>bestSteps=3</pre>
<pre><span class="lnum"> 10: </span> </pre>
<pre><span class="lnum"> 11: </span>[simplelevel LevelLeaderboard]</pre>
<pre><span class="lnum"> 12: </span>bestTime=95.921692</pre>
<pre><span class="lnum"> 13: </span>bestScore=6700</pre>
<pre><span class="lnum"> 14: </span>bestSteps=336</pre>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0tag:blogger.com,1999:blog-6001082585535661666.post-49193723525632937942012-09-27T09:24:00.000+02:002012-10-01T15:50:52.392+02:00Cookbook: Getting started with UDK<i>I'll try to post here some tips on UDK and its usage ups and downs, as I'm encountering them.</i><br />
<br />
<h3>
First steps:</h3>
<div style="text-align: justify;">
<ol>
<li>Essentially you need your UDK install, grab it from <a href="http://udk.com/">udk.com</a></li>
<li>As a programmer, I recommend using some (your favorite) version control system, for your created/edited files. I'm currently using free <a href="http://tortoisehg.bitbucket.org/">TortoiseHg </a>(which is Mercurial). Its big advantage is the ability to work without any server/internet connection (basically it's its own server)</li>
<li>use your favorite IDE for files editing (<a href="http://notepad-plus-plus.org/">notepad++</a> is good). I'm currently using VisualStudio2010 due to its fast search options and scrollbar highlighting (with free <a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef?SRC=Home">Productivity Power Tools</a> extension). I have also Visual Assist installed to speed up file lookup, snippets, etc. In Visual Studio it is advised to create a custom solution and you can add some post build step to be able to compile unreal script ("<span style="font-family: Courier New, Courier, monospace;">call %UDK_INSTALL_DIR%\Binaries\Win64\UDK.exe make</span><span style="font-family: inherit;">"</span><span style="font-family: Courier New, Courier, monospace;">)</span></li>
<li><span style="font-family: inherit;">grab <a href="http://udn.epicgames.com/Three/UnCodeX.html">UnCodeX</a>, which is basically a tree overview of all classes and dependencies in unrealscript of your UDK install (your changes included). <b>This is strongly recommended!</b></span></li>
<li>you can find help on internet, remember, if you have encountered some problem somebody before you probably had had the same problem and already solved it! Best sources are:</li>
<ul>
<li>UDN documentation at
<a href="http://udn.epicgames.com/Three/WebHome.html">http://udn.epicgames.com/Three/WebHome.html</a></li>
<li>forums at
<a href="http://forums.epicgames.com/">http://forums.epicgames.com</a></li>
<li>youtube, google</li>
</ul>
</ol>
</div>
<h3>
<span style="font-family: inherit;">Tips:</span></h3>
<div>
<ul>
<li>try as much as possible to create new files and not edit existing ones (you'll avoid problems with moving to newer UDK releases), this applies to unrealscript as well as data packages! Keep clear dir structure (you need to be able to find it)!</li>
<ul>
<li>my example:</li>
</ul>
</ul>
<span style="font-family: Courier New, Courier, monospace;">%UDK_INSTALL_DIR%</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Development</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Src</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> BallPuzzler </span><span style="font-family: inherit;">- all my code</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> UDKGame</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Config</span><span style="font-family: inherit;"> - all custom and edited configs are here</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Content</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> UDK_Project </span><span style="font-family: inherit;">- all my data packages</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Flash</span><span style="font-family: inherit;"> - scaleform menu</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Movies</span><span style="font-family: inherit;"> - BINK videos</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Splash</span><span style="font-family: inherit;"> - custom splash screen</span><br />
<ul><ul>
<li>create your custom configs (for example for input):</li>
<ul>
<li>usage in code:</li>
</ul>
</ul>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span><span class="kwrd">class</span> BallPuzzlerInput extends PlayerInput within BallPuzzlerController</pre>
<pre><span class="lnum"> 2: </span> config(BallPuzzlerInput);</pre>
</div>
<ul><ul><ul>
<li><span style="white-space: pre;"><span style="font-family: inherit;">you actually create </span><i style="font-family: inherit;">default </i><span style="font-family: inherit;">config (e.g. </span><span style="font-family: Courier New, Courier, monospace;">DefaultMyCoolConfig.ini</span><span style="font-family: inherit;">), engine will on startup create <i>UDK</i> version of it (i.e. </span></span>
<span style="font-family: 'Courier New', Courier, monospace; white-space: pre;">UDKMyCoolConfig.ini)</span></li>
<li><span style="white-space: pre;"><span style="font-family: inherit;">still in code you refer to it </span><b style="font-family: inherit;">without prefix</b><span style="font-family: inherit;">, i.e. </span><span style="font-family: Courier New, Courier, monospace;">config(</span></span><span style="white-space: pre;"><span style="font-family: Courier New, Courier, monospace;">MyCoolConfig)</span></span></li>
</ul>
<li>there is unfortunately one exception that I haven't found a way to avoid: <span style="font-family: Courier New, Courier, monospace;">UDKGame\Config\DefaultEngine.ini</span><span style="font-family: inherit;">, here you'll have to put your edits to make things work...</span></li>
<ul>
<li><span style="font-family: inherit;">let's take a look at what needs to be edited in </span><span style="font-family: Courier New, Courier, monospace;">DefaultEngine.ini</span><span style="font-family: inherit;">:</span></li>
</ul>
</ul>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>[URL]</pre>
<pre><span class="lnum"> 2: </span>Map=SimpleMainMenu.udk <span class="rem">//name of your default map (used by Unreal FrontEnd when cooking game!)</span></pre>
<pre><span class="lnum"> 3: </span>LocalMap=SimpleMainMenu.udk</pre>
<pre><span class="lnum"> 4: </span> </pre>
<pre><span class="lnum"> 5: </span>[Engine.ScriptPackages]</pre>
<pre><span class="lnum"> 6: </span>+NonNativePackages=BallPuzzler <span class="rem">//add your script package to be recognized by engine</span></pre>
<pre><span class="lnum"> 7: </span> </pre>
<pre><span class="lnum"> 8: </span>[UnrealEd.EditorEngine]</pre>
<pre><span class="lnum"> 9: </span>+EditPackages=BallPuzzler <span class="rem">//add your script package to be recognized by editor</span></pre>
</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<br />
<ul><ul><ul>
<li>some additional non-essential changes:</li>
</ul>
</ul>
</ul>
<!-- code formatted by http://manoli.net/csharpformat/ -->
<br />
<div class="csharpcode">
<pre><span class="lnum"> 1: </span>[Engine.Engine]</pre>
<pre><span class="lnum"> 2: </span>GameViewportClientClassName=BallPuzzler.BallPuzzlerViewportClient <span class="rem">//overrides default class that sends messages to loading screen!</span></pre>
<pre><span class="lnum"> 3: </span> </pre>
<pre><span class="lnum"> 4: </span>[FullScreenMovie]</pre>
<pre><span class="lnum"> 5: </span>+StartupMovies=Logo <span class="rem">//currently NOT working (UDK July 2012), I had to replace original startup video (Logo.bik in Movies dir)</span></pre>
<pre><span class="lnum"> 6: </span>LoadMapMovies=Transition <span class="rem">//specify your transition movie (.bik in Movies dir)</span></pre>
</div>
<br />
<h3>
<ul>
<li><span style="font-size: small;"><span style="font-weight: normal;">very good tutorial for first simple game (my inspiration as well ;), is at </span></span>
<a href="http://labs.vectorform.com/2011/11/creating-a-side-scrolling-game-with-udk/" style="font-weight: normal;"><span style="font-size: small;">http://labs.vectorform.com/2011/11/creating-a-side-scrolling-game-with-udk/</span></a></li>
<li><span style="font-size: small;"><span style="font-weight: normal;">to play/test your game and level in editor, don't forget to change </span>GameType <span style="font-weight: normal;">in <span style="font-family: Courier New, Courier, monospace;">View/WorldProperties</span></span></span></li>
</ul>
</h3>
</div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<ul><ul>
</ul>
</ul>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/09123776869426876912noreply@blogger.com0