Game Development and
Simulation with Unreal
Technology
إخالص
هذا الكتاب إخالص لعائلتي ،التي ساعدتني حبها ودعمها
غير المشروط خالل مساعي األكاديمية والمهنية
Contents
Preface مقدمة xv
Contributor مساهم Xxiii
Acknowledgments تقدير Xxv
SECTION I Unreal Technology Basics: Introductory Development
Techniques
تقنيات التطوير التمهيدية:أساسيات تكنولوجيا انريل
Chapter 1 Setting Up Unreal Project
Templates ..............................................3
Introduction.............................................................................3 1.1
Unreal Project Types...............................................................3 1.2
Blank Projects and Content Migration ...................................4 1.3
First Person Projects ............................................................. 10 1.4
Third Person.......................................................................... 14 1.5
Side Scroller.......................................................................... 17 1.6
Top Down Templates ............................................................ 20 1.7
Summary............................................................................... 24 1.8
Exercises ............................................................................... 24 1.9
Chapter 2 Introduction to Level Design in
Unreal......................................... 27
Introduction and Objectives.................................................. 27 2.1
Establishing the Geometry.................................................... 27 2.2
Geometry Brush Overview ...................................... 33 2.2.1
Improving the Level Aesthetics with Materials.................... 55 2.3
Refining the Geometry and Adding Meshes......................... 60 2.4
Refining the Level with Lighting.......................................... 67 2.5
Adding Functionality ............................................................ 70 2.6
Summary............................................................................... 82 2.7
Exercises ............................................................................... 82 2.8
Chapter 3 Unreal
Blueprints........................................................................... 85
Introduction to Unreal Blueprints......................................... 85 3.1
A Tour of Unreal Blueprint Editor........................................ 85 3.2
Graph Editor.............................................................85 3.2.1
Types of Blueprints...............................................................85 3.3
Level Blueprints.......................................................86 3.3.1
Class Blueprint......................................................... 87 3.3.2
Data-Only Blueprints............................................... 87 3.3.3
Variables, Functions, and Events ..........................................92 3.4
Events.......................................................................92 3.4.1
Functions..................................................................93 3.4.2
Variables...................................................................93 3.4.3
Class Blueprints vs. Level blueprints ...................................93 3.5
Construction Script ............................................................... 97 3.6
Components Mode................................................................ 97 3.7
Components ............................................................. 97 3.7.1
Components Events and Functions..........................98 3.7.2
Creating Your Own Class blueprints ..................................106 3.8
User Input and Interaction ..................................................110 3.9
Action Mappings....................................................110 3.9.1
Axis Mappings....................................................... 111 3.9.2
Summary.............................................................................122 3.10
Exercises .............................................................................123 3.11
Chapter 4 Materials in Unreal
Technology ..................................................125
Introduction.........................................................................125 4.1
What Is a Material?.............................................................125 4.2
Materials vs. Textures ............................................126 4.2.1
Texture Coordinates (UVs) .................................... 127 4.2.2
Unreal Material Editor........................................................ 127 4.3
The Toolbar............................................................128 4.3.1
Preview Window ....................................................128 4.3.2
Graph Canvas.........................................................128 4.3.3
Details Panel ..........................................................129 4.3.4
Expressions Palette ................................................129 4.3.5
Physically Based Materials in Unreal Engine 4 .................129 4.4
Anatomy of an Unreal Engine 4 Material...........................130 4.5
Material Nodes....................................................... 131 4.5.1
Material Channels .................................................. 131 4.5.2
Material Shading Models....................................... 147 4.5.3
Material Domain ....................................................148 4.5.4
Material Blend Mode .............................................149 4.5.5
Material Expressions in Unreal 4 .......................................178 4.6
Parameter vs. Non-Parameter Expressions ............180 4.6.1
Commonly Used Material Expressions .................180 4.6.2
Constant Expressions............................. 181 [Link]
Mathematical Expressions.....................182 [Link]
Coordinate Expressions.........................206 [Link]
Depth Expressions.................................222 [Link]
Font Expressions ...................................223 [Link]
Parameter Expressions...........................224 [Link]
Particle Expressions............................... 227 [Link]
Texture Expressions...............................228 [Link]
Utility Expressions ................................234 [Link]
Vector Expressions ................................255 [Link]
Summary.............................................................................256 4.7
Exercises ............................................................................. 257 4.8
:SECTION II Making Game Worlds Stand Out
Intermediate Development Concepts
Chapter 5 Advanced Material
Concepts....................................................... 261
Introduction......................................................................... 261 5.1
More about Unreal Engine’s Shading Models.................... 261 5.2
Default Lit.............................................................. 261 5.2.1
Unlit .......................................................................262 5.2.2
Subsurface..............................................................262 5.2.3
Preintegrated Skin..................................................263 5.2.4
Clear Coat ..............................................................263 5.2.5
Subsurface Profile ..................................................263 5.2.6
Material Blend Modes ........................................................263 5.3
Opaque Blend Mode ..............................................264 5.3.1
Masked Blend Mode..............................................264 5.3.2
Translucent Blend Mode........................................264 5.3.3
Additive Blend Mode.............................................264 5.3.4
Modulate Blend Mode ...........................................265 5.3.5
More Advanced Material Expressions................................265 5.4
Parameter Expressions ...........................................265 5.4.1
Particle Expressions ...............................................270 5.4.2
Blends ................................................................................. 277 5.5
Physically Based Materials in Unreal Engine 4 .................278 5.6
Material Functions in Unreal Engine 4...............................279 5.7
Material Attributes Expressions .........................................282 5.8
Layered Materials ...............................................................283 5.9
Material Layer Blend Types...................................284 5.9.1
Material Instances and Dynamic Material Modifications...286 5.10
Decals .................................................................................286 5.11
Decal Blend Mode .................................................286 5.11.1
Post Process Materials ........................................................ 287 5.12
Refraction and Reflection ................................................... 287 5.13
Summary.............................................................................288 14.
Chapter 6 Visual Effects in Unreal
Engine ..................................................289
Introduction.........................................................................289 6.1
Anatomy of Visual Effects..................................................289 6.2
Particles..................................................................289 6.2.1
Particle System.......................................................290 6.2.2
Emitter Actor .........................................................290 6.2.3
Emitter....................................................................290 6.2.4
Module ...................................................................290 6.2.5
Particle System Component...................................292 6.2.6
Distributions...........................................................292 6.2.7
Unreal Cascade Particle System Editor ..............................292 6.3
Simulation Viewport ..............................................294 6.3.1
Emitters List...........................................................294 6.3.2
Details Panel ..........................................................295 6.3.3
Curve Editor...........................................................295 6.3.4
Particle Specific Materials Setup ........................................295 6.4
Particle Expressions ...............................................296 6.4.1
CPU-Based Sprite Emitters ................................................296 6.5
GPU-Based Sprite Emitters ................................................325 6.6
GPU vs. CPU Particles ..........................................325 6.6.1
Working with Sub UVs.......................................................335 6.7
Particle Type Data Modules................................................352 6.8
GPU Sprites Type Data..........................................352 6.8.1
Beam Type Data.....................................................355 6.8.2
Mesh Type Data ..................................................... 357 6.8.3
Ribbon Type Data ..................................................360 6.8.4
Summary.............................................................................362 6.9
Exercises .............................................................................362 6.10
Chapter 7 Designing Terrains and Outdoor
Environments ..........................365
Introduction to Landscapes.................................................365 7.1
Landscape Setup .................................................................366 7.2
Creating A Landscape............................................ 367 7.2.1
The Landscape Manage Tab (Creation Mode).......368 7.2.2
Landscape Materials ........................................................... 377 7.3
How Landscape Materials Blend ........................... 377 7.3.1
Landscape Material Expressions............................378 7.3.2
Editing Landscapes.............................................................418 7.4
Landscape Sculpt Mode.........................................418 7.4.1
Landscape Paint Mode...........................................423 7.4.2
Manage Mode ........................................................425 7.4.3
Landscape Splines ..............................................................426 7.5
Creating Splines..................................................... 427 7.5.1
Joining Splines....................................................... 427 7.5.2
Splitting Splines..................................................... 427 7.5.3
Assigning Static Mesh Actors to Splines............... 427 7.5.4
Editing Splines.......................................................428 7.5.5
Applying Splines to a Landscape...........................428 7.5.6
Foliage and Foliage Editor..................................................440 7.6
Foliage Tools..........................................................442 7.6.1
Culling Instances....................................................445 7.6.2
Water in the Landscape.......................................................459 7.7
Summary.............................................................................473 7.8
Exercises .............................................................................474 7.9
SECTION III Example Games: Advanced Game
Development Concepts
Chapter 8 Advanced Blueprint
Concepts.....................................................479
Introduction.........................................................................479 8.1
Communication between Blueprints...................................479 8.2
Direct Blueprint Communication...........................479 8.2.1
Blueprint Casting ...................................................479 8.2.2
Event Dispatchers ..................................................480 8.2.3
Blueprint Interfaces................................................ 481 8.2.4
Chapter Synopsis ................................................................ 481 8.3
Creating The HUD..............................................................500 8.4
Saving and Loading Game Data .........................................519 8.5
Summary.............................................................................534 8.6
Chapter 9 A Top-Down Game with
Blueprints............................................535
Synopsis..............................................................................535 9.1
Setting Up the Level ...........................................................536 9.2
Character, Controller, and Game Mode Blueprints ............ 537 9.3
Character Movement and User Input..................................543 9.4
Projectile Class Blueprint and Functionality ......................548 9.5
Firing Mechanism .................................................. 551 9.5.1
Setting Up Collisions .............................................558 9.5.2
Creating the Enemy Class and Implementing Damage ......563 9.6
Enemy Damage Implementation............................565 9.6.1
Implementing the Player Damage..........................568 9.6.2
Implementing Game Over!!! ..............................................572 9.7
AI and Enemy Spawning ....................................................575 9.8
Spawning Enemies.................................................575 9.8.1
Setting Up Enemy Artificial Intelligence............... 581 9.8.2
Particle Systems and Visual Effects....................................588 9.9
Destruction Visual Effects .....................................588 9.9.1
Hit Visual Effects...................................................590 9.9.2
Summary.............................................................................602 9.10
Appendix A Unreal Engine 4 Material Expressions
Reference.......................603
Appendix
A............................................................................................................60
3
A.1 Introduction.........................................................................603
A.2 Atmosphere Expressions ....................................................603
A.3 Color ...................................................................................603
A.4 Constant Expressions..........................................................604
A.5 Coordinate Expressions ...................................................... 607
A.6 Depth Expressions ..............................................................610
A.7 Font Expressions................................................................. 611
A.8 Function ..............................................................................612
A.9 Material Attributes Expressions .........................................614
A.10 Math Expression .................................................................615
A.11 Parameters Expressions ......................................................625
A.12 Particles...............................................................................630
A.12.1 Particle Macro UV: ................................................ 631
A.13 Landscape ...........................................................................634
A.14 Texture ................................................................................636
A.15 Utility..................................................................................638
A.16 Vector Operations ...............................................................645
A.17 Vector Expressions..............................................................645
Appendix B Distributions in Unreal Engine
4 ................................................. 647
Appendix
B ............................................................................................................
647
B.1 Introduction......................................................................... 647
B.2 Float Distributions .............................................................. 647
B.2.1 DistributionFloatConstant...................................... 647
B.2.2 DistributionFloatUniform ...................................... 647
B.2.3 DistributionFloatConstantCurve ............................648
B.2.4 DistributionFloatUniformCurve.............................648
B.2.5 DistributionFloatParticleParam..............................649
B.3 Vector Distributions ............................................................649
B.3.1 DistributionVectorConstant....................................650
B.3.2 DistributionVectorUniform .................................... 651
B.3.3 DistributionVectorConstantCurve.......................... 651
B.3.4 DistributionVectorUniformCurve ..........................652
B.3.5 DistributionVectorParticleParam ...........................653
Appendix C The Curve Editor in Unreal Engine
4..........................................655
Appendix
C ............................................................................................................65
5
C.1 Introduction.........................................................................655
C.2 Curve Editor Layout ...........................................................655
C.3 Curve Editor Controls.........................................................655
C.3.1 Mouse Controls......................................................655
C.3.2 Keyboard Controls .................................................656
C.3.3 Shortcuts ................................................................656
C.4 Interpolation Modes............................................................ 657
C.4.1 Auto........................................................................ 657
C.4.2 Auto Clamped ........................................................ 657
C.4.3 User........................................................................658
C.4.4 Break......................................................................658
C.4.5 Linear .....................................................................659
C.4.6 Constant .................................................................659
References.................................................................................................
............ 661
Index..........................................................................................................
............665
Preface
المقدمة :باختصار عن كماليات المحرك ،لدرجة انك يمكنك
استخدامه للذكاء االصطناعي Unreal Technology .تطورت
عما كانت عليه ،فهي في السابق لغة برمجة UnrealScript
وهي لغة مشابهة ل ،++C/Cهي األداة تفاعل مع المحرك.
رًدا على االستقبال الكبير الذي حظي به محرك Unreal
،Engineأطلقت Epic Gamesشبكة مطوري ).Unreal (UDN
كان UDNمركًز ا صاخًبا عبر اإلنترنت لمستخدمي Unreal
Engineوالمبرمجين والمطورين ،للعثور على معلومات
ووثائق محدثة حول الميزات المختلفة للمحرك.
مصدر الشفرة :source codeأي لغة البرمجة أو الكود
الذي انشأ كود معين ،مثل انك تقول Unreal Scriptمصدر
الشفرة خاصتها . ++C
طبعًا عبر تاريخ انريل أصدرت Epic Gamesنسخة من
محرك Unreal Engine 3مجانًا للطالب والمطورين ،باسم
) Unreal Development Kit (UDKلكنه ال يحتوي على
البرمجة بلغة .++C
ما الذي يغطيه هذا الكتاب؟
كما يوحي االسم حول تقنية انريل ،بالذات تطوير األلعاب.
في هذا الكتاب ،سنغطي مكونات Unreal Engineالتي تعتبر
أساسية جًدا في تطوير اللعبة وسنتعرف على الميزات
التالية في :UE4
Material
:Chapter 4يقدم لك كيفية إنشاء materialكمبتدأ.
:Chapter 5يقدم لك ميزات اكثر تقدمًا لل ،materialمثل:
shading models, layered materials, and material
.instancing
Blueprint Scripting System
يقصد هنا ب Blueprintوليس شيئًا آخر ،وفي هذا الكتاب
سيكون مقصرًا لبناء Blueprintمتقدم.
:Chapter 3مقدمة حول Blueprint
:Chapter 8يجعلك تتعمق أكثر في البرمجة باستخدام
مخططات ،UE4في تقديم مفاهيم مثلcasting, blueprint :
,communications, event dispatchers
CASCADE PARTICLE SYSTEMS
هو باختصار نظام الجسيمات المتتالية مثل :الغبار والشرار.
طبعًا هذا النظام له نوع ملف خاص ،وهو تلقائيًا يعمل
بالمعالج ويمكنك جعله يعمل بال ،GPUليظهر بشكل أجمل.
:Chapter 6يغطي جميع المفاهيم المطلوبة لنظام Cascade
.Particle Editing
Landscapes
هذه هي التي من خاللها يمكنك صنع التضاريس ،ويمكنك
إضافة materialمخصص لتلك التضاريس كجعل الحواف
بلون آخر.
:Chapter 7إن هذا الفصل سيشرح كيفية إنشائه.
Project Templates
طبعًا هنا نقصد قوالب المحرك كمنظور الشخص األول
والثالث.
:Chapter 1هذا الفصل هو الذي يشرح تلك القوالب ،لكن
لن اقدمه في تلك المراجعة النه تافه جدًا وانا لست مبتدأ.
Contributors
Andrew Morales: Chapter 1و Chapter3وChapter8
Jeff Cavazos: Chapter 9
Thomas Brantley: Chapter 4
:Isaac Elenbaasساهم إسحاق في تحديث المحتويات إلى
اإلصدار األخير من .Unreal Engine
Acknowledgments
لم يكن هذا الكتاب ممكًنا لوال دعم Epic Gameللتعليم وتفانيهم
في المجال األكاديمي .أود أن أشيد بالساعات التي ال تعد وال
تحصى التي قضوها في إنشاء هذه األنشطة العملية الممتعة
والتعليمية.
Section I
Unreal Technology Basics:
Introductory Development
Techniques
:أساسيات التكنولوجيا ألنريل
تقنيات التطوير التمهيدية
Chapter 1: Setting Up Unreal Project Templates
Chapter 2: Introduction to Level Design in Unreal
Chapter 3: Unreal Blueprints
Chapter 4: Materials in Unreal Technology
لن نقدمه لكن المختصر،طبعًا الفصل األول
:المفيد منه هو
والذي من خالله يمكننا نقل مجلد من: …Migrate.1
.مشروع إلى مشروع آخر
وتلك الخاصية موجودة:Use Control Pawn Rotation .2
والذي من خالله يمكننا تدوير الكاميراCameraBoom في
. مع جعله يتأثر بحركة الشخصية،بالماوس
CH.2 A Premier on Level
Design in Unreal Technology
عرض أول عن تصميم المستوى
في التكنولوجيا ألنريل
Introduction And Objectives 2.1
في هذا الفصل لن نفترض أي معرفة بأي محرك لعبة أو إصدارات
سابقة من .Unreal Engineلبناء المستوى األول ،يجب علينا
استخدام ( ،)BSPثم ستكون خطوتنا الثانية هي إنشاء اإلضاءة
لمستوانا.
ESTABLISHING THE GEOMETRY 2.2
إحدى المراحل األولى لتصميم المستوى هي تحديد الشكل
الهندسي لمستواك .في معظم الحاالت ،إذا كنت تستخدم Unreal
،Engineفسوف تنجز هذه المهمة عن طريق هندسة الفرشاة.
CREATING A FIRST PERSON PROJECT
اآلن ،سنقوم بإنشاء مشروع FIRST PERSONمع تضمينه
.Starter Contentوقم بتسميته ":"LevelDesignProject
انشأ مشروع FIRST PERSONمن نوع .Blueprint .1
وتأكد من تسميتك له ""LevelDesignProject .2
CREATING A LEVEL WITHIN THE PROJECT
سنقوم اآلن بإنشاء مستوى جديد والبدء في ملء عملية التصميم
الخاصة بنا.
في لوحة ال toolbarاضغط على :…File>New Level .3
في الشاشة التالية ،اضغط على :Basic .4
:SkySphereهذا هو الممثل الذي يعرض السحب وضوء
النهار.
:DirectionalLightهذا هو الذي يدور الشمس.
:Atmospheric Fogهذا التأثير هو وجود كمية قليلة الضباب
في المشهد ،مما يجعل األشياء البعيدة تبدو غير واضحة بعض
الشيء.
:Player Startيتم استخدام هذا الممثل لبدء موقع شخصية
الالعب عند بدء اللعبة.
:Floor Static Meshهي باختصار األرضية.
.5يمكنك تشغيل اللعبة بواسطة ، Ctrl+Pأو بالضغط على رمز
< األخضر.
Ctrl+Shift+S .6
HIDING THE PLAYER MESH
اآلن نريد ان نخفي الالعب:
في ،Content Browserافتح مخطط .7
FirstPersonCharacterوانقر على ال.Viewport
في لوحة ال ،Viewportانقر على .FirstPersonMesh .8
وفي لوحة ال ،Detailsقم بالتمرير ألسفل وابحث عن قسم .9
ال Renderingوقم بإلغاء مربع .Visible
.Compile .10
اآلن إذا لعبت المستوى لن ترى االيادي للشخصية. .11
REMOVING THE PLAYER START AND THE
PLATFORM
اآلن سنزيل ،player startلكي نجعل الالعب يبدأ من حيث موقعه في
محرر المستوى:
احذف player startوحاول ان تختبر النتيجة. .12
ESTABLISHING THE DEFAULT AND STARTUP
LEVELS
هناك طريقة يمكنك من خاللها تحديد Default Levelهذا من اجل
إذا كنت تريد تحديد الخريطة االفتراضية التي تفتح لك ،عند
تشغيل انريل مرة أخرى.
.13في لوحة األدوات اعلى آخر شي اذهب عند > Edit
.Project Setting
.14في االقسام الموجودة على اليسار اضغط على
.Project > Maps & Modes
.15في الجهة األيمن لكي تغير الماب االفتراضي فقط
يجب عليك اختيار المستوى في القائمة عن Default
Maps > Editor Startup Map
GEOMETRY BRUSH OVERVIEW 2.2.1
Geometry Brushهي األداة األساسية في Unreal Engineوالتي
يمكنك من خاللها تصميم المستوى .وتلك األدوات هي البديل
األساسي لبرامج التصميم مثل 3ds Max :أو .Maya
قال المؤلف" :هناك عدة مراحل في سير العمل لتطوير
المستوى ،بدًءا من حظر المستوى وإنشاء مسارات
داخل المستوى ،للعب اختبار التدفق وطريقة اللعب،
وصوًال إلى التمريرة "البولندية" النهائية" .
يقول المؤلف عن مراحل تطوير اللعبة ،بدءًا من حظر المستوى
أي تحديد العناصر األساسية مثل التضاريس ،والجدران ،والعقبات،
وبعدها يتم إنشاء مسارات داخل المستوى أي تحديد األماكن
التي سينتقل فيها الالعب من بداية المستوى إلى نقطة النهاية،
ومن ثم اختبار اللعبة والتأكد من انة طريقة اللعب ممتعة ،وانة
اللعبة خالية من األخطاء والقلتشات ،وفي المرحلة األخيرة
التمريرة "البولندية" النهائية يقصد بتلك الجملة ب اللمسة
األخيرة حيث نركز على التفاصيل الغير مهمة مثل جودة الصوت
واإلضاءة.
ُتستخدم فرش الهندسة في مرحلة تحديد العناصر األساسية
إلنشاء التصميم األساسي للمستوى .بعدها تتم مرحلة اإلضاءة،
بعد المرور األولي للشبكة واإلضاءة ،يتم اختبار االصطدامات
وعوامل األداء األخرى .بمجرد حل جميع مشكالت األداء المتبقية،
ستكمل مرحلة التلميع النهائية جماليات اللعبة ،من خالل إضافة
تأثيرات خاصة وعناصر صوتية ومرئية أخرى.
الشكل Stages of Level Design :2.6
ستكون هندسة الفرشاة مفيدة للغاية في مرحلتين من عملية تصميم
المستوى .وكما تم شرحه أعاله ،في المرحلة األولية من العملية ،تعتبر
الفرشاة أداة مهمة لتحديد الهندسة األساسية للمستوى .تمنحنا الفرش
طريقة سريعة لتصميم كل "هندسة الحشو" هذه في محرر Unreal Editor
دون الحاجة إلى االعتماد على أداة نمذجة ثالثية األبعاد من جهة خارجية.
الشكل Geometry Tab (b) Brush Setting )a( :2.7
61