码迷,mamicode.com
首页 > 编程语言 > 详细

从Unity引擎过度到Unreal4引擎

时间:2015-03-03 15:19:55      阅读:8210      评论:0      收藏:0      [点我收藏+]

标签:ue4   unity   unreal4   ue4基础教程   

 前言

        寒假回家到现在已经有十多天了,这些天回家不是睡就是吃....哎╮(╯▽╰)╭,今天早上一觉醒来,突然得知,UE4免费了,这绝对是个好消息,前不久我还在纠结怎么申请校园账号呢o(╯□╰)o。迫不及待打开电脑下载了UE引擎的一个类似管理的客户端,在里面最醒目的一栏,看到一个令人哭笑不得的导航,如下图:

  技术分享

       EPIC这是要逆天的节奏吗?不过不管他了,接下来,我们便一同学习一下EPIC提供给我们的这篇从Unity过渡到UE4的经验之谈吧。说明一下,下面我将对这篇文章中的重点内容做翻译和一些自己的见解,仅供参考,若需更详细的内容,请访问官方提供的文档手册。

      原文目录:https://docs.unrealengine.com/latest/INT/GettingStarted/FromUnity/index.html?utm_source=uelauncher&utm_medium=software&utm_campaign=learntab


那我们就开始吧

The Editor  编辑器

两个编辑器的布局如下:

技术分享


Editing Assets编辑资源


Detail面板就是负责编辑工程资源,类似于Unity里面的Inspector。

技术分享

Quick Glossary(Glossary:术语)

 两个引擎的部分术语对比:

Category Unity UE4
Gameplay Types Component Component

GameObject ActorPawn

Prefab Blueprint Class
Editor UI Hierarchy Panel World Outliner

Inspector Details Panel

Project Browser Content Browser

Scene View Viewport
Meshes Mesh Static Mesh

Skinned Mesh Skeletal Mesh
Materials Shader MaterialMaterial Editor

Material Material Instance
Effects Particle Effect Effect, Particle, Cascade

Shuriken Cascade
Game UI UI UMG (Unreal Motion Graphics)
Animation Animation Skeletal Animation System

Mecanim Persona , Animation Blueprint
2D Sprite Editor Paper2D
Programming C# C++

Script Blueprint
Physics Raycast Line Trace, Shape Trace

Rigid Body Collision, Physics
Runtime Platforms iOS Player, Web Player Platforms

Projects and files工程和文件

So what are all these directories and files?工程目录和文件的具体内容?

Just like Unity projects, Unreal projects always exist in their own directory and have their own project file. You can double-click on .uproject files to load your game into the Unreal Editor, or right click for additional options. Project folders have various sub-folders that contain your game‘s content and source as well as various configuration files and binaries. The most important are the Content and Source sub-folders.就像Untiy的工程一样,Unreal4的每一个工程都有他们单独的工程文件夹。可以通过双击.uproject 文件打开工程,或者通过右键查看更多选项。UE4的工程文件夹包含很多子文件夹和文件,里面最重要的是Content和Source 文件夹

Where do I put my assets?我应该把资源放在那里?

In UE4, each project has a Content folder. Similar to a Unity project‘s Assets folder, this is where your game assets are stored. To import assets into your game simply drop files into your project‘s Content directory and they will be automatically imported and appear in the Content Browser. The assets in the editor will update automatically as you make changes to the files using an external program.UE4的工程文件夹里面的Content文件夹和Unity的Asset文件夹类似,用来存放游戏资源。可以通过拖拽的方式,载入资源,对资源进行处理过后,UE4工程将会自动在Content文件夹和ContentBrowser面板中更新资源信息。

技术分享

What common file formats are supported?支持的文件格式

UE4所能支持的一些文件格式

Asset Type Supported Formats
3D .fbx, .obj
Texture .png, .jpeg, .bmp ,.tga, .dds, .exr, .psd, .hdr
Sound .wav
Fonts .ttf, .otf
Videos .mov, .mp4, .wmv

How is my Scene stored?场景文件是如何存储的呢?

In Unity you place GameObjects in a scene and save that as a Scene asset file. Unreal has a Map file that is similar to a Unity Scene. Map files store data about your Level and the objects in it, as well as lighting data and certain level-specific settings.Unity中我们把GameObject放置到场景里面,并以场景资源的形式存储。在UE4的工程中Map文件类似于Unity中的Scene文件。Map文件存储了关卡里面的物体,同样的包括光照信息,和关卡本身特定的属性。

How do I change my project‘s settings?如何更改工程设置

All project settings can be found from the main menu under Edit / Project Settings. Like Unity‘s project settings, these allow you to specify information about your project (such as project name and icons), configure game input bindings, and define how the engine behaves when running your project. You can learn more about individual project settings here. Unity also has what‘s called "player settings". In Unreal, these are "platform settings", and can be found under the "Platforms" category in your project settings.

可以在Edit / Project Settings 工程设置中更改工程的名字啊,图标啊,设置输入的绑定信息啊,定义引擎如何在你的项目中运行,还可以选择平台。

Where do my source files go?源文件是如何运行的

In Unity you‘re accustomed to placing C# source files in your assets folder.在Unity中,我们习惯于把C#文件放置在资源文件夹Assets里面。

UE4 works differently. For projects that have C++ code, you‘ll find a "Source" sub-folder under the project directory that has various files, including C++ source (.cpp) and header (.h) files, as well as some build scripts (.Build.cs, .Target.cs) However, Blueprint-only projects won‘t have a Source folder.但是UE4却不是这样的。对于用C++创建的UE4,你将会在游戏工程文件夹下找到Source子目录,里面存放了包含.h,.cpp和各种文件。然而通过蓝图创建的工程没有Source文件夹。

The easiest way to get started with C++ in UE4 is to use the editor to Add Code to Project (in the main File menu), or to simply create a new C++ project from scratch from one of the many templates. You can find C++ classes right in the Content Browser and can open the files in Visual Studio or Xcode by double-clicking on their icons.UE4中开始使用C++最简单的方式是通过编辑器中的 Add Code to Project 命令。或者通过C++工程模板创建的工程只需要在ContentBrowser里面双击代码就可以用VS打开了。

From GameObjects to Actors 从GameObjects到Actors

Where Is My GameObject?Unit中GameObject在UE4中如何体现?

In Unity, a GameObject is a "thing" that can be placed in the world. The UE4 equivalent(等价) is an Actor. In the Unreal Editor, you can drag a new Empty Actor into the viewport from the Placement panel:

在Unity中,GameObject是一个可以放置在世界里面的东西。UE4中的Actor与之等价,在编辑器里面,我们可以拖放一个空的actor到世界里面。

技术分享

You could build a game out of Empty Actors, but UE4 also includes special(特定的) types of Actors with built-in features, such as a Pawn (for players or AI objects), or Character (for animated creatures.) Just like Empty Actors, you can drop these special types of Actors down, then add or customize their properties and components. You‘ll learn more about it later, but for now try to remember that UE4 has a Gameplay Frameworkthat works with these special Actors.

你可以使用一个空的Actor来创建自己的游戏,但是UE4内置了很多有特定功能的Actor类型,比如Pawn(是针对players和AI角色),Character(针对有动画的生物)。和普通的空Actor一样,我们可以拖拽这些Actors到场景师徒,并且定制他们的属性和组件。稍后我们将学到这部分内容,但是最重要的是记住,UE4有一个 Gameplay Framework 系统来使用这些Actors工作。

Actors in UE4 are a bit different than GameObjects in Unity. In Unity, GameObject is C# class which you can‘t directly extend. In UE4, Actor is a C++ class which you can extend and customize using inheritance. We‘ll talk about this more later on!

UE4中的Actors和Unity中的GameObject有很多不同。Gameob是C#的类,不可以直接扩展。而在UE4中,Actors是c++的类,你可以扩展并且拖过继承的方式自定义。稍后我们将继续学到这部分内容。

Where Are My Components?Unity中的组件在UE4中如何体现?

In Unity, you add components to a GameObject to give it functionality.在Unity中我们可以通过给一个物体组件来给他添加功能。

In UE4, you add components to Actors. After you‘ve dropped an Empty Actor in your level, click the Add Component button (in the Details panel) and choose a component to add. Here, we‘re creating a torch by dropping an empty actor, then adding a mesh component for the base, followed by a light source and then a particle system to create its flame.空物体--添加组件(mesh、light、particle )制作火把,看下图即可

1.拖放空Actor,为其添加StaticMesh组件

  技术分享

技术分享

2.在Mesh组件的层级上,添加点光源组件

技术分享

3.Mesh上添加例子Particle组件

技术分享

技术分享


In Unity, a GameObject hold a flat list of components, but in UE4 an Actor actually contains a hierarchy of components attached to one another. You can see this in the example above, where the Light and Particle are attached to the Mesh. This has some important implications discussed later in Complex Actors and GameObjects.

Unity中一个GameObject的所有组件的关系是平行的,但是在UE4中,一个Actor的组件之间可以存在层次关系。如上面火把的例子中,Light和Particle组件就是依附在Mesh组件上。等下将会在Complex Actors and GameObjects这一节中讨论更多重要的概念。

From Unity prefabs to UE4 Blueprint Classes  Unity中的prefabs对应UE4中对应蓝图类

Unity‘s workflow is based on prefabs. In Unity you build a set of GameObjects with components, then create a prefab from them. You can then place instances of the prefab in your world, or instantiate them at runtime.

Unity的工作流程是基于prefabs的,我们创建一系列具有组件的GameObjects,然后通过他们创建预设,然后我们就可以拖放一个实例到世界中或者在运行的过程中动态生成实例。

UE4‘s corresponding workflow is based on Blueprint Classes. In UE4, you build an Actor with components, select it, and click the "Blueprint / Add Script" button (in the Details panel). Then, choose a place to save your Blueprint Class, and click "Create Blueprint" to save your new Blueprint Class!

UE4中相对应的工作流程是基于蓝图类的。在UE4中,你可以你可创建一个拥有组件的Actor,选中它,并且在Details面板中点击 "Blueprint / Add Script"按钮,然后选择一个位置存放蓝图类,最后点击保存。


Your new Blueprint Classes can be found in the Content Browser. You can double-click to edit them directly, or you can drag and drop them into any level.我们新创建的蓝图类可以再Content Browser面板中找到,我们可以通过双击他们直接打开,并且我们可以把它们拖放到任意的关卡之中。

Where is Script Component and MonoBehaviour? Unity中的脚本组件和MonoBehaviour中在UE4中如何体现?

In Unity you have Script Components that you drop on GameObjects to add C# scripting. You create a class that inherits from MonoBehaviour to define what that component does.

在Unity中,我们可以给GameObject添加C#脚本,这个脚本继承自MonoBehaviour 来定义组件的功能。

UE4 has something similar. You can create whole new Component classes of your own and drop those onto any Actor. You can create Component classes using either Blueprint Scripting or C++.

So how do you create your own component class in UE4? In the Detail panel‘s Add Component drop-down, you see you can create new components, or choose existing ones:

UE4中也有一些类似的东西。我们可以创建完全空的组件并且把它们赋给Actor(对比Unity中需继承MonoBehaviour )。我们可以通过C++或者蓝图的形式创建组件。在UE4中如何创建自己的独有的组件呢?答案是在Detail面板中的 Add Component 下拉选项中,我们可以创建新的组件或者选择已有的组件。

技术分享

In Unity, when creating a new MonoBehaviour you, will be given a skeleton(概要?) class file with a Start() function and an Update() function.

在Unity中,当我们创建一个新的MonoBehaviour 时,会提供给我们一个包含Start()函数和Update()函数的类。

In UE4, you will also be given a skeleton class with a InitializeComponent() function and a TickComponent() function, which perform functions similar to Start and Update.

If you create a Blueprint Script Component you will be given these same functions as visual nodes:

在UE4中,系统也将提供给我们两个函数,他们分别是 InitializeComponent() 函数和 TickComponent()函数,这两个函数和Unity中Start()函数和Update()函数类似。当我们创建一个蓝图脚本组件的时候,系统也将提供给我们两个具有类似功能的可视化节点。

技术分享

Scriptable Actor Blueprint Classes 可以编辑的Actor蓝图类

Here is a cool feature in UE4: Your new Actor Blueprint Class can have its own Blueprint Visual Scripting! This allows you to add logic to an entire object, not only an individual component. Combined with inheritance (explained below), this gives you a lot of flexibility when designing your game.UE4中有一个非常酷的功能:你新建的 Actor蓝图类(此处不是组件蓝图类)可以使用蓝图来实现可视化编辑。这意味着你可以对整个物体添加逻辑,而不仅仅是这个物体中一个特定的组件。这将在你设计自己的游戏中提供更大的灵活性。

In addition to Blueprint Classes supporting visual scripting, UE4 also supports C++ Classes implemented with code. Here are both, side-by-side.

除了可以可视化编辑的蓝图脚本之外,UE4也支持通过代码实现功能的C++类。下面给出了三个的对应关系。

Unity c#

using UnityEngine;
using System.Collections;

public class MyComponent : MonoBehaviour
{
    int Count;

    // Use this for initialization.
    void Start ()
    {
        Count = 0;
    }

    // Update is called once per frame.
    void Update () 
    {

        Count = Count + 1;
        Debug.Log(Count);
    }
}
UE4 C++

#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class AMyActor : public AActor
{
    GENERATED_BODY()
    int Count;

    // Sets default values for this actor's properties.
    AMyActor() 
    {
        // Allows Tick() to be called
        PrimaryActorTick.bCanEverTick = true;  
    }

    // Called when the game starts or when spawned.
    void BeginPlay()
    {
        Super::BeginPlay();
        Count = 0;
    }

    // Called every frame.
    void Tick(float DeltaSeconds)
    {
        Super::Tick(DeltaSeconds);
        Count = Count + 1;
        GLog->Log(FString::FromInt(Count));
    }
};
UE4蓝图

技术分享

UE4 Blueprint Classes can be extended。  UE4的蓝图类可以被扩展

Unity prefabs and UE4 Blueprint Classes can be instantiated in your game similarly. However, Unity has complications related to nesting prefabs within other prefabs, which limit their role as extensible building blocks.

In UE4, you can create a new Blueprint Class which extends an existing Blueprint Class and augments it with new properties, components, and visual scripting functionality.Untiy的prefabs预设和UE4的蓝图类能够在你的游戏中相似的实例化出来。然而,Unity有一些并发机制,他们和预设与预设之间的嵌套相关,这些机制决定或者说限制了他们成为可以在构建时被扩展(这儿有点难理解,看下面的例子吧)。

For example, in UE4 you can create a Blueprint Class named Monster(怪物) which implements basic monster functionality such as chasing people. You can then create further Blueprint Classes which extend it, such as Dragon (a type of Monster which adds fire-breathing features), Grue (a Monster which is likely to eat you when it‘s dark), and for example 8 others. These subclasses of Monster all inherit the basic functionality from Monster, and add new capabilities on top.

例如,在UE4你可以创建一个命名为怪物的蓝图类实现基本功能, 比如追赶人类。然后您可以创建更多的蓝图类来扩展它,如龙怪物(对其添加喷火的功能),雪怪(一中可以再黑暗的时候吃掉你的怪物),和其他八种怪物等等。这些怪物的子类都是从一开始创建的有基本功能的怪物类继承而来,并在其基础上添加新功能。

In Unity, you would implement this by creating many different GameObject prefabs: one for Dragon, one for Grue, and so on. Now, say you want to add some new functionality to all monsters, such as the ability to speak using your new Speak Component. In Unity, you have to go and update all 10 prefabs to individually copy and paste the new functionality into it.

在Unity中,你的世界通过创建不同的GameObject实例(比如一个作为龙怪,一个作为雪怪等等)来实现这一功能。现在,如果你想给所有的这些怪物添加一些新的功能,比如使用你新创建的Speak组件让他们有能力说话,在Unity中,你不得不对这十个实例单独的更新,来为它们添加功能。

In UE4, you can simply modify the Monster Blueprint Class to add this new ability to speak. That‘s all! Dragon, Grue, and the 8 other subclasses of Monster automatically inherit the new speaking functionality, and you don‘t need to touch them.

在UE4中,你可以简单的修改最初的父类怪物蓝图脚本类添加新的说话功能,仅仅这么做就够了,无论是龙怪,雪怪或者其他八种Monster父类的子类都会自动的继承新的说话的功能,你都不用去单独的指定它们。

But there‘s more! Everything we have said here about Blueprint Classes also applies to C++ Classes, and everything is equally true of actors and components. These systems are designed to support large-scale development of extensible functionality, and can scale to projects with 10‘s or 100‘s of developers.但是不止如此,我们在这里说的一切蓝图类也适用于c++类,包括组件和Actor类。这些系统是为了扩展而被设计的,包括开发大规模可扩展的功能,以及项目开发10人到100人的开发人员人数的扩展。(一字一字的翻译就是:“这些系统是为了用来支持大规模开发可扩展的功能,并且可以扩展项目10或100的开发人员所设计的”,反正就是这么一个意思,容易扩展)。

Should I use Blueprint Scripting, C++, or both?我应该使用C++,蓝图还是都使用呢?

Blueprint Visual Scripting is ideal for simple in-game logic flow and sequencing of actions. It‘s a great system for designers, artists, and visually-oriented programmers, because it‘s easy to access and control in-game objects visually. You can even create small standalone-game using just Blueprints; see the Tappy Chicken sample for a full-fledged example.蓝图这种可视化的编辑脚本对于简单的游戏逻辑和一些简单操作的排序是理想的。对于设计者,艺术家和一些以视觉为导向的程序员来说,蓝图脚本是一个非常棒的系统,因为我们可以非常方便通过可视化的方式实现和控制游戏物体。甚至,你可以仅仅使用蓝图来创建小的单独的游戏。可以参考Tappy Chicken例子来查看这部分的具体实现。

C++ programming is for larger-scale tasks, such as building gameplay systems, complex AI, and new engine features. If you already have some C++ experience, check out the Introduction to C++ Programming in UE4 page.C++编码是用来做一些大规模的任务的,比如创建游戏的框架,复杂的AI和一些新的引擎的功能。如果你有一些C++的经验,可以之间去查看 Introduction to C++ Programming in UE4 这一页。

Most projects will use a mix of Blueprints and C++. Many developers prototype game functionality using Blueprints, because it is so easy and fun, and later move some or all of it to C++ for performance and engineering rigor.大多数的工程会混合使用蓝图脚本和C++脚本。许多开发者愿意使用蓝图脚本规范游戏的功能,因为它非常简单有趣,然后不就考虑到规范,和性能问题,会把其中的一部分甚至全部移植到C++程序。

Blueprint Classes can extend C++ Classes 蓝图类可以用C++类扩展

Much of the magic of UE4 game development comes from the interplay between programmers implementing new features in C++, with designers and artists utilizing them in Blueprints and then asking for more! Here‘s how a team might structure a UE4-based shooter game implementing pickups using a mix of C++ Classes systems programming, and Blueprint Classes for behaviour and appearance:UE4游戏开发的魔力来自蓝图脚本和C++脚本的共同作用。程序员使用C++实现新功能,设计师和艺术家在蓝图脚本中使用它们,实现新的功能,在需要新功能时再向程序员提出。下面是一个实例,展示了一个团队如何同时使用C++构建一个射击游戏的框架,使用蓝图类用来实现具体行为和一些外观等功能。

技术分享

       接下来的内容就是有关代码部分了,今晚抽空继续更新~



   



    

从Unity引擎过度到Unreal4引擎

标签:ue4   unity   unreal4   ue4基础教程   

原文地址:http://blog.csdn.net/u011707076/article/details/44036839

(0)
(3)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!