- Einführung in Unity - Fachprojekt DET SS 2019€¦ · • Game Engine für 2D und 3D Anwendungen...

Post on 30-Apr-2020

4 views 0 download

Transcript of - Einführung in Unity - Fachprojekt DET SS 2019€¦ · • Game Engine für 2D und 3D Anwendungen...

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Fachprojekt DET SS 2019- Einführung in Unity -

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Einführungin

Unity

2

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Überblick1. Was ist und was kann Unity2. Editor3. Definitionen4. Scripting5. Interaktionen/Kommunikation6. Ressourcen

3

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Was ist Unity• Game Engine für 2D und 3D Anwendungen• Programmiersprache C#• Viele unterstützte Plattformen• Großer Asset Store• Kostenfrei bis zu einem bestimmten Umsatz

4

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Was kann Unity• Sehr viele Spielumsetzungen• Teils schlechter Ruf durch

Spiele bestehend aus Assetsaus dem Store

• 2D, 3D, VR, AR, … Anwendungen• ...

5

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Was kann UnityRapid Prototyping• https://itch.io/jam/brackeys-2• https://globalgamejam.org/2019/games

6

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Editor

7

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: Szene• Eine Szene setzt sich aus GameObjects zusammen

8

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: GameObject• GameObjects bestehen aus Komponenten

und erhalten dadurch ein Verhalten

• Ein GameObject hat einen Namen undeinen Tag

9

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: Komponenten• Jedes GameObject hat eine

Transform Komponente• 3D Modelle haben einen

Mesh Filter, einen Mesh Rendererund ein Material

10

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: Physikkomponenten• Rigidbodies und Collider gehören

zur Physics Engine• 3D und 2D Varianten

11

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: Layer• Kollisionserkennung in Abhängigkeit von Layers

12

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: Weitere KomponentenKomponenten für…• Networking• Rendering• 2D• Audio• AI• UI• ...

Weitere Beispiele:• Kamera• Audio Listener• Animator• Line Renderer• Particle System• Sprite Renderer• …

13

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Definitionen: Prefab• Ein Prefab ist eine Blaupause für ein GabeObject• GameObjects werden als Prefab im Asset Browser

abgespeichert• Prefabs können zur Laufzeit instanziiert werden

14

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Scripting: MonoBehaviour• Komponenten sind abgeleitete Klassen von

MonoBehaviour

• Eigene Komponenten (oder Scripte) erben von MonoBehaviour

15

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Scripting: Lifecycle

16

Unity Manual

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Scripting: Lifecycle

17

Unity Manual

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Scripting: Lifecycle

18

Unity Manual

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Scripting: Event Functions• Awake()

– Wird vor Start() ausgeführt• Start()

– Wird vor dem ersten Frame Update ausgeführt• FixedUpdate()

– Wird in konsistenten Zeitintervallen aufgerufen• Update()

– Wird jeden Frame aufgerufen

19

Scripting Reference

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Scripting: Event Functions• OnEnable() / OnDisable()

– Wird bei der Aktivierung und Deaktivierung von einem GameObject aufgerufen

• OnTrigger() / OnCollision()– Wird bei einer Kollision aufgerufen

• OnDestroy()– Wird aufgerufen, sobald das GameObject zerstört

wird

20

Scripting Reference

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Interaktionen/Kommunikation• Member Variablen serialisieren:

– [SerializedField] private float carSpeed = 1.0f;oder

– public GameObject car;

21

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Interaktionen/Kommunikation• Referenzierung von Komponenten per Inspector:

22

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Interaktionen/Kommunikation• Referenzierung von Komponenten per Script:

– PlayerController playerController= GetComponent<PlayerController >();

23

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Interaktionen/Kommunikation• Referenzierung von Komponenten per Script:

– GameObject player = GameObject.FindGameObjectWithTag(“Player”);

– PlayerController playerController =player.GetComponent<PlayerController>();

24

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Interaktionen/Kommunikation• Referenzierung von Komponenten per Script:

– GameObject player = GameObject.FindGameObjectWithTag(“Player”);

– PlayerController playerController =player.GetComponent<PlayerController>();

25

Marco Pleines | Dortmund, 02.04.2019

Lehrstuhl 11 Fakultät für Informatik

Ressourcen• Unity User Manual• Unity Scripting Reference• Unity Learn• Unity Standard Assets

26

• Unity3D College• Hollistic3d• Brackeys• Catlike Coding Text Tutorials