当前位置:网站首页>Unity3d famous project-Dark Tree translation

Unity3d famous project-Dark Tree translation

2022-08-10 06:28:00 Liu Shigang

Dark Tree
组件概述
•Statistical character and life
•武器
•The controller animation
•Inventory and things
•建筑系统
•Tutorials and help
感谢您购买DTFPS.This game template allows you to easily prototype a survival game.
在本手册中,I would like to know more about the tools and methods used in the project and some
入门教程
The main goal of this asset is to provide an easy setup experience and the ability to make shooters fast
但请记住,Your game needs more work than ready-made templates in the asset store. 它会 Don't make the game for you yourself,but will give you a good starting point. Sometimes you still need to work If you want to expand the pack and make your game truly unique and original,请使用代码. 如果你熟悉 C# and can write your own scripts It is easy to start using DTFPS 设置,但是您仍然可以使用 Provide tooling and customize it as needed without scripting
我希望你会喜欢它,This bunch of tools and scripts will make your development process easier 并且更快.
组件概览 是时候从基础开始了.
DTFPS Contains many different scripts and game objects,But we can only outline the scripts we will use during our work.To begin using the package,您需要将 GamePrefab Drag your scenario. This is the main game object,包含玩家、库存、Save and load system, etc.
GamePrefab
让我们来看看 GamePrefab 扩展的层次结构.
这里我们有 6 个游戏对象. You can get their function by the way they call. Player – Is a player controller,可以行走、射击、Collect items, and other.
Inventory canvas – is a complete inventory system placed on a bunch of canvas objects
Canvas Main – 主 UI 画布,Contains the players health、十字线、All weapons such as visual interface Name and ammo count, etc.
WeaponManager&HitFXManager – Empty practical game object,Store only the components required by the system 工作. Mobile input canvas – is a canvas containing mobile input rigs and other mobile devices. EventSystem – 处理 UI 事件所需的 Unity 标准对象.
此外,We store important components in GamePrefab 上. 看看下面的图片.

We'll outline the components we sometimes need to use. Utility objects that do not need to be set are ignored
输入管理器 - A utility script that contains player action keymaps and toggles for mobile input work
声音管理器 - Store some audio effects for player events
Cover List 是 AI The actor's good helper. It stores all available covers in the scene,AI Get the cover. Don't need to add here cover,Because it will automatically work
WeaponManager&HitFXManager
WeaponManager:This is we need to open/关闭对象、隐藏/Cancel the hidden weapon、装备/Cancel the equipped weapon components. 不久,For all things shared with armed weapon status.

在这里,We have to open the/Closed weapon list and inventory equipment panel. Every interactive device panel must be placed in this list,in order to provide information on equipped weapons.
HitFXManager :is a component that stores different effects for melee and bullet hit events.

Hit Particles :Hit particles are separated by type of surface bullet hit.
Impact sound:Crash is the sound that plays when a melee weapon hits something(will vary with different types of surfaces also).
Ricochet sounds:Bounce sound is played on surface impact.
The decal here can also be applied to different types of surfaces. Here you can control the decal pool and set the pool size for each decal type.
Character 注意:在以前的版本中,The character is made with rigid bodies and a capsule collider,但从 1.4 Version of the physical switch to CharacterController 组件.Role is to include all weapons、动画、The player statistics(健康、口渴、饥饿)And other controller logic(如运动)的游戏对象, Swimming and gym.
PlayerConsists of different game objects,You can find them in the hierarchy

Player拥有 5 个组件,但我们对 FPS Controllers are interested and player stats only. 让我们来看看它们
Player holds 5 components but we interested in FPS Controller and Players Stats only. Let’s take a look at them.

FPS Controller:
The most of fields are describe themselves with the name they has. I’ll describe only important fields here.
Most fields describe themselves Use their name. I will describe only the important areas here.

Lock Cursor – Is cursor should being disabled on start?
Cam Holder – Is the object that contains camera child
Sensitivity – mouse sensitivity for each axis
Smoothing – smoothing coefficient for mouse axes
锁定光标 - Whether the cursor should be disabled on startup?
Cam Holder – is the object containing the camera children
灵敏度 - Each shaft of the mouse sensitivity
平滑 - The mouse shaft smooth coefficient
Landing and air are settings for player air states
Landing and Air are settings for the player's air state
Soft Landing Sound – sound being played when player hit the ground after jump if air time is not bigger than ‘HardLandingTime’
Hard Landing Sound – being played if ‘HardLandingTime’ is bigger than air time.
Gravity – gravity value applied to the player down force
Distance To Wall Raise weapon – distance to wall when player should play weapon raise animation.
A soft voice - If the flight time is not more than“HardLandingTime”,the sound played when the player lands after jumping
Hard Landing Sound – 如果“HardLandingTime”More than playing time,则播放.
Gravity – Gravity value applied to the player's downforce
Distance To Wall Raise Weapon – The distance from the wall when the player should play the weapon lift animation.
Player stats

The script has player life stats, linked settings and objects.
The script has player life stats、Link set and object.

Is God – player immortal if true
Health – player health point (int)
Health UI Text – a text to draw hp on the screen
Health UI Slider – a slider to draw hp stripe
是上帝 - 如果为真,Players will be immortal
健康 - Player health(int)
Health UI Text - Used to draw on the screen hp 的文本
Health UI Slider - 用于绘制 hp Stripe slider

(All the same for hunger and thirst)

Min Failing Damage – Minimal damage if player fallsfrom height
Damage Screen FX – an UI image that will be shown if playerget damage
Damage Screen Color – additional color to control fximage color.
Damage Screen Fade Speed – how fast damage fxwill disappear
Use Consume system – if true player’s life stats will decrease aftertime
Hydration, satiety are survival live stats.
Substraction rate – is a time to decrease one point of stat (in sec).
Hunger/satiety damage – damage point to decrease player healthif stat is zero and subtraction time up to time.
Pain Clips – Audioclips to play on player hurt (height failing, bullet hit etc.)

(Hunger and thirst are all the same)

Minimum damage failure - If you fall from grace,伤害最小
Damage the screen FX – Displayed when the player takes damage UI 图像
Damage to the screen color - 控制 fximage The color of the additional color.
Damage screen ramp speed - Damage effect disappeared
Use consumption system - If the real player's health stats will decrease after
水合作用、Satiety is a real-time survival statistic.
Subtracting rate - is the time to reduce one statistical point(以秒为单位).
饥饿/Full abdomen feeling hurt - If the statistics of zero,Then reduce the damage points and subtraction time of the player's health.
Pain clips - Audio clip that plays when the player is injured(高度下降、The bullet, etc)

Weapons
You can create any weapon with DTFPS. You can create rifle, pistol, sniper, rocket launcher, and any other firearmweapon with Weapon Wizard
您可以使用 DTFPS Create any weapons. You can craft a rifle using the weapon wizard、手枪、狙击手、Rocket launchers and any other gun weapons

To start creating new weapon you need to apply your weapon model to weapon object field and press next
To start creating new weapons,You need to apply the weapon model to the weapon object field,然后按下一步

After that you need to create weapon helpers and set them up to correct position. Muzzle flash transform mustbe at the end of weapon barrel and shell transform must be at the place where shell are being ejected. Also setup yourweapon with the camera position and make sure that all weapon child are on ‘Weapon’ layer.
之后,You need to create weapon helpers and set them to the correct position. The muzzle flash transformation must be at the end of the weapon barrel,The shell transformation must be where the shell is ejected. Also set your weapon with camera position,and make sure all weapon kids are in“武器”层上.

Next step is to set up animations for your new weapon. When you go to Animator tab you’ll probably see thismessage…
The next step is to animate your new weapon. 当您转到 Animator 选项卡时,You may see this message…

Often, unity generates animator component for each skinned meshes and now you have default animator on yourweapon object. Remove that.
通常,unity For each skin grid generation animation component,Now your weapons on the object with the default animation component. 去掉那个.
Now your Animator tab must look like the picture below.
Let’s see to fields we have there.
Only 4 animation clips required for weapon properwork. It is shot, idle, reload, aim animations. Otheranimation are additional and not required by default.
We can animate item take events. When player look atitem take begin animation will started then take loopanimation.
And if you take item take animation will beplayed. It’s advanced item interaction animations.
Second shot and third shot animations are to makeshooting animation various.
After you done with animation clips setting press‘Create animator’ and go forward.
现在您的 Animator TAB must be shown in the figure below.
Let's see where we are in the field.
Weapons work normally need only 4 Animation clips. It is shooting、空闲、重新加载、Aimed at the animation. Other animation is extra,默认情况下不需要.
我们可以为 item take Event set animation. When the player sees the item start the animation will start and then loop the animation.
If you take the project take the movie will be played. This is a senior project interactive animation.
The second and third shot animations are to diversify the shooting animation.
After complete animation clips set,按“Create the animator”并继续.

Weapon setting tab will ask you to create new weapon scriptable object. You need to click that button and after that you will see new weapon settings list
The weapon settings tab will ask you to create a new weapon script object. You need to click the button,Then you will see a list of new weapon settings

Weapon type :
First field is weapon type.
Shot or melee attack sound effect :
Second is weapon attack sound (shot, melee attackswoosh etc.)
Recoil Vector :
Recoil will move camera to some value on x or y axison shot.
Weapon damage:
Weapon damage value has min and max damage.Final damage calculates with random range betweenthese two values.
Aim camera FOV :
Aim camera FOV changes main camera FOV on aim
Will use UI scope :
Set will use UI scope if your weapon should useaiming with scope
Rigidbody hit force :
Rigidbody hit force value applied to rigidbody objecton hit
Fire rate in shot per second :
Fire rate in shot per seconds tells how fast yourweapon will shot bullets
Spread default factor:
Spread factor is value that applied to spread vectorfor bullet direction
Bullet initial velocity:
Bullet initial velocity in meter per seconds. You canset realistic bullet speed.
Bullet air resistance factor :
Air resistance factor influence on bullet speed andworks like air friction.
Bullet pool size/ Shell pool size:
And here is pools for bullets and shells. They areshould have the same value as weapon ammo capacity
Shell ejecting force :
Force will be applied to shell rigidbody on shot
Muzzle flash effect :
Particle system to play muzzle flash effect on shot. Will be spawned on muzzle flash transform
Reloading sounds effect:
Weapon empty sound effect Played if weapon has no ammo but player shooting
Shell object prefab:
Find in prefabs folder
Bullet prefab:
Find in prefabs folder
武器类型:
The first field is the weapon type.
Shooting or melee attacks sound:
The second is sound weapons to attack(射击、Such as melee attacks)
Recoil vector:
Recoil Will move the camera to x 或 y On the shaft of a value.
武器伤害:
Weapon damage values ​​have min and max damage.Final damage is calculated in a random range between these two values.
Aimed at the camera FOV :
Aimed at the camera FOV Aimed at changing the main camera FOV
将使用 UI 范围:
If your weapon should use a scope,Set 将使用 UI 瞄准镜
In rigid body shock:
Rigidbody hit force The hit force value applied to the rigid body object
A second shot firing rate:
The rate of fire per second indicates how fast your weapon fires bullets
Spread the default coefficient:
The scatter factor is the value applied to the scatter vector in the direction of the bullet
The bullet velocity度:
The bullet velocity(米/秒).You can set realistic bullet speed.
The bullet air resistance coefficient of:
Effect of Air Drag Coefficient on Bullet Velocity,Role similar to the air friction.
The bullet pool size/Shell pool size:
Here is the bullets and shells pool. They should have the same value as weapon ammo capacity
Hulling force:
The force will be applied to the shell rigid body when firing
枪口闪光效果:
Particle system plays muzzle flash effect when shooting. Will be generated when the muzzle flash transforms
Reinstall the sound:
Weapon null sound is played when the weapon has no ammo but the player shoots
Shell object fabrication:
在 prefabs 文件夹中查找
The bullet prefabricated:
在 prefabs 文件夹中查找
After setting finish you need to turn off your weapon in inspector and create weapon item. You cant leave weaponsenabled due to inventory system limitations. All weapons must be associated with item objects and now we’ll createthis one.
设置完成后,You need to close the weapon in the inspector and create the weapon item. Because the inventory system restricted,You can't enable weapon. All weapons must be associated with an item object,现在我们将创建这个.
Go to DTInventory tab and click Create Item button
转到 DTInventory 选项卡并单击 Create Item 按钮

Drag your weapon model (without hands and animations) to itemmodel field. You can add rigidbody and collider to your object here but incollider will be generated only if your gameobject has meshfiltercomponent (gameobject is mesh). Usually, meshes grouped to emptygameobject and has no meshes on it, In this case you can create colliderby yourself. Now press next.
Will your weapon model(No hand and animation)拖到 itemmodel 字段. You can add to the object here and rigid body collision,but only if your game object has a mesh filter component(The game object is the grid)Will only generate collision device. 通常,Grid grouped into an empty game object and there is no grid,在这种情况下,You can create the collider yourself. Now click on the next step.

Your new item will be instantiated at your scene. Complete itemfields and continue. Make sure that item Type is the same as yourequipment panel allowed type. In other case, item will not be equippedand used in inventory! To learn more about item fields look atDTInventory manual
Your new item will be instantiated in your scene. To complete the project field and continue. Make sure the item type is the same as your device panel allows. 否则,Items will not be equipped and used for inventory! To learn more about item fields,请查看 DTInventory 手册s

Controller animations
As you may already know, we use animations to make weapon walk bobbing, camera bobbing, animate weapon changing and some other. We need get to know the main components we use and animate in the system.
您可能已经知道,We use animation to make the weapon walk and swing、Camera swings、Weapons, Change and some other. We need to understand the main components we use and animate in our system.

Lean controller is procedural transform that allows player to lean out of corners. It has special Lean script with obstacle check so you won’t dive your head throughh the wall
Lean controller is a program transformation,Allow players to lean out of the corner. It has special lean scripts with obstacle checking,so you don't put your head through the wall

Weapon holder is an animator of walking,running, crouching,jumping etc. Also there is an animations to show/hideweapon. To edit these animation you need to selectweapon holder and open animation window.
Weapons holder is to walk,跑步,蹲伏,跳跃等动画.还有一个动画显示/Hidden weapon. To edit the animation,You need to select the weapon rack and open the animation window.
Sway gameobject allows your weapons to sway when camera is moving.And last one is the MainCamera – Recoil – HeadBob. Here we have animator that animate camera bobbing. You can examine animations with opening animator. It is the same process as for weapon holder.
The swing game object allows your weapon to swing as the camera moves.最后一个是 MainCamera - Recoil - HeadBob. 在这里,We have animators to animate the camera wobble. You can check the animation with the open animator. This is the same process as for weapon holders.
Inventory and Items
You can learn about inventory and items in DTInventory manual. You can find it in DTFPS folder.But you need to know about specific components of DTFPS item system. And it is consume events script.We call this script events when use some item. There isalready events to add health, satiety, hydration.Action Wait Timer will freeze player for some time. Youcan set timer to zero if you do not want item use waiting.Action wait text will show what action player performingat this time. For example, we can use medkit and freeze playerfor healing time and show ‘healing’ text on screen.Also we can attach sfx for event action.
您可以在 DTInventory Learn about inventory and items in the manual. 你可以在DTFPS文件夹中找到它.但是你需要了解DTFPSPart of the specific system. It is consumption event script.We call this script event when we use some item. There are already events that increase health、饱腹感、水合作用.Action Wait Timer Will freeze players for a period of time. If you don't want to use waiting for the project,You can set the timer to zero.The action waiting text will show the action the player is performing at the moment. 例如,我们可以使用 medkit and freeze the player's healing time and display it on the screen“治疗”文本.We can also add sfx For event operations.

Building system

Building system allows you to create building using inventory items. For some people it looks complicated and hard but it’s very easy in fact.Let’s see how to create new building.We need to create new building scriptable object first. Right click in project view → create → building data.Let’s what we’ve got here…Building name will drawn in building select windowDescription is not used for now but will show buildingdescription in future.Building Game Object – it’s the next step. I will tell aboutit little bit later.Assign building iconAnd final building cost items. This array should containsingle items that we use for building. Cost Items array shouldcontain cost of each array item for building. Take a look at thepicture bellow.
The building system allows you to create buildings using inventory items. 对有些人来说,Seems complicated,其实很简单 Right click in the project view → 创建 → Building data.Let's get here what…Building names will now be drawn in the building selection window without description,but will show the building description in the future.Building the game object - 这是下一步. 稍后我会讲到.Distribution of architectural ICONS and the final cost of construction project. This array should contain the single item we use for the build. Cost Items The array should contain the build cost for each array item. 看看下面的图片.

Here we have Branch and Cloth items which arerequired for shelter building. Cost for both items are 4. Itmeans we need to have 4 Branches and 4 Cloth items ininventory in order to build a shelter.We missed Building Game Object field. Do youremember? Now I will show you how to make it.This is firecamp building (you can find it in your assets folder). Pivot point of the building must be on ground because if your pivot somewhere at the middle, you object will fall through the ground in a half size. Object layer is ‘Ignore Raycast’, set it for your own buildings too. Attach Object Place Utility script and set surface tag for placement.And we must have a collider for the object in order to touch the ground with it. Collider must be little bit lower of object pivot (bellow the ground little bit). Now drag you new object to prefabs folder and set it to scriptable object field.
在这里,We have branches and cloth items needed to build the shelter. The cost of the two items are 4.
This means that we need to have 4 A branch and 4 fabric items to build a shelter.
We missed building the game object field. 你还记得吗? Now I will show you how to make it.
这是 firecamp 建筑(You can find it in your assets folder).
The pivot point of the building must be on the ground,because if your pivot is somewhere in the middle,Your object will fall to half the size of the ground.
Object layer is“Ignore the light cast”,Also set up for your own building.
Attach object placement utility script and set surface markers for placement.
We have to set a collider for the object,In order to use it to contact with the ground.
The collider must be slightly below the object pivot(Slightly lower than the ground).
Now drag your new object to the prefab folder and set it to the Scriptable Object field.

Last thing we have to do. Is to attach our new scriptable object to building manager list. Find it in the hierarchy
the last thing we have to do. is to append our new scriptable object to the building manager list. In the hierarchy to find it

You will see Building Manager Script in the inspector. Drag and drop your new building scriptable object to buildings array. It’s all. Now you can build your own objects. Graphics data and UI will be automatically generated.
You will see in the viewer Building Manager Script. Drag and drop your new building script object to Building array. 这就是全部. Now you can build your own object. 图形数据和 UI 将自动生成.

Tutorials and helpCheck out tutorials on YouTube chanel :www.youtube.com/channel/UCv… link :discord.gg/r6wRYA2
user guide
内容
工作原理
Listing introductory guide
组件概述
基本脚本
常见问题解答
How it works
First of all, thank you for purchasing my asset! I sincerely hope that my work will help you to develop your games and save a lot of time for you.
Inventory always was a sort of magic for me. There is almost no tutorials about how to make inventory with Diablo/S.T.A.L.K.E.R. grid placement. In this overview I want to give you a knowledge how this inventory works so that you understand what you are doing and there was no mystery left.Inventory is a collection of grid cells with X and Y indexes with free/occupied bool state. It’s all! When we trying toplace an item to the grid we ask inventory next questions. Do we have enough space to store item? Where we can placeitem with specified width and height?
这个怎么运作
First of all thank you for purchasing my assets! I sincerely hope that my work will help you develop your game and save you a lot of time.
Inventory is always a magic for me. almost nothing about how to use Diablo/S.T.A.L.K.E.R. Make inventory tutorial. The grid to place. 在本概述中,I want to tell you how this inventory works,so you know what you're doing,and there is no mystery.Inventory is a X 和 Y The index with free/a collection of grid cells occupying a boolean state. 都是! When we try to place the project to the grid,We'll ask the next question in stock. We have enough space to store items? where can we place items with specified width and height?

Each item has width and height. Width and height it is a space which item will take on a grid. Here we have an item with a size of width 3 andsize of height 1. Width 3 means that our item will take 3 grid cells on horizontal and 1 on vertical for height. Since we know space required for item storing, wecan tell inventory to find suitable cell for us.Inventory find cells with this construction x+width, y+height.For example, if inventory will get slot 0,0 as a starting point, andslots 0,0;1,0;2,0 will be free, we can store that item on a grid.Otherwise, if one of the cells is occupied by another item then . we will not be able to put the item there.And finally, if we place item to the grid, inventory marksx+width, y+height cells as occupied. If we start dragging item toother position, we just mark these cells as free and mark new ones as not.It’s a brief explanation of how DT Inventory works. Of course we have a lot of other different methods but it’s essential knowledge give you vision of inventory construction. You can meet with other utility methods in source code.
Each item has width and height.The width and height are the space the items will take up on the grid. Here we have a width to 3 和高度为 1 的项目.宽度 3 Said our project will occupy 3 Horizontal grid cell and 1 The vertical grid cell height. Since we know the space required for item storage,We can tell the inventory for us to find the right cell.Inventory lookup hasx+宽度,y+Height of the structure of the cell.例如,If the stock will receive slot0,0作为起点,And the slot0,0;1,0;2,0 将是空闲的,We can store that item on the grid.否则,If one cell is occupied by a another project,则 . We won't be able to put items there.最后,If we place the items into the grid,Inventory tags x+宽度,y+Height is occupied cell.If we start to item Drag to another location,We just need to mark these cells as free,And are marked as new cell not.这是对 DT Inventory The working principle of the brief explanation.当然,We have many other different methods,但它是 The basics give you a vision for inventory building.You can use other utility methods in your source code.

Getting started with inventory wizard

Open the Inventory Wizard with the toolbar at the top and press ‘New Inventory’ 2) Use the toolbar at the top to open the Inventory Wizard,然后按“新建库存”

Set up fields of Wizard and press ‘Build Inventory’ 3) Setup wizard in the fields and press“Build the inventory”

Inventory Horizontal sizeInventory levels sizeNumber of grid cell onvertical/horizontal axis of the gridInventory Vertical sizeInventory vertical sizeNumber of grid cell onvertical/horizontal axis of the gridNormal cell colorNormal cells colorSet of colors to draw normal/hovered/blocked state of the cellHovered cell colorHover cell colorSet of colors to draw normal/hovered/blocked state of the cellBlocked cell colorBe prevented from cell colorSet of colors to draw normal/hovered/blocked state of the cellStack text fontStack text fontFont of stack text drawerStack text colorStack text colorColor of stack textCell sizeSize of grid cell in pixelsCell imageSprite image to draw cellBackground colorColor of background panelThe background panel colorInventory backgroundInventory backgroundSprite image for background panelBackground panel elf image
After you’ve created a new inventory you can also create a loot window and equipment slots. I’ll tell about their functionality little bit later. So lets go on!
After creating a new inventory,You can also create loot windows and equipment slots. Later I will introduce their function. 所以让我们继续吧!
Loot window

Click on ‘Loot window’ tab and complete fields. Click ‘Build Loot Window’ as you will done. Loot Horizontal size and Vertical size are the same with inventory settings. It’s an X and Y size of our grid. Set position of the window on screen. 5) 单击“Loot window”TAB and fill in the fields. 完成后单击“Build loot window”. The loot horizontal and vertical dimensions are the same as the stock settings. This is our grid X 和 Y 尺寸. 设置窗口在屏幕上的位置.

We made loot window but for a what? This window will be used as loot box/chest representation. It’s a special grid that will contain items from chest and provide control on ‘em for us.
Congratulations! You’ve made your own inventory from blank in a few minutes. Inventory is fully functional right now and it’s working but who would to use equipment slots? Your game has armor and weapons? If yes you probably will be glad to know that equipment panels creation as simple as the actions above.
We made the loot window,But for the sake of what? This window will use the loot box/The representation of a box. This is a special grid,will contain items from the chest and give us control over them.
恭喜! You've made your own stock from blank in minutes. Inventory is now fully functional and running,But who will use equipment slot? Does your game have armor and weapons? 如果是,You may be happy to know that the creation of device panels is as easy as above.
Equipment panels

Click on ‘Equipment panels’ tab and complete fields. Press ‘Build panels’ and set position of the equipment panels on the screen. 6) 单击“设备面板”TAB and fill in the fields. 按“构建面板”and set the position of the device panel on the screen.

Equipment panels countNumber of equipment panels you want to create. You can setup panel for required item typeThe number of device panels to create. You can set the panel for the desired item typeEquipment horizontal sizeX grid sizeEquipment vertical sizeY grid sizeAllowed item typeEach Item has string field called ‘Type’. It’s like unique tag for different type of items. Here you can put allowed item type. Others are not will be equipped.Each project is famous for“类型”的字符串字段. It's like unique labels for different types of items. You can put allowed item types here. Other equipment will not.
Do you see similar picture on your screen?
Do you see a similar picture on the screen?

If yes, we continue with items and interactions. If no, something went wrong. You can try again or contact me at email below. Also look for video tutorial on YouTube.
如果是,We continue to project and interaction. 如果没有,就出问题了. You can try again or contact me via email below. 还可以在 YouTube Looking for video tutorials on.
Items
We can create items manually and with item wizard. Each item is a prefab with the Item.cs component. Item has to be created within scene and saved to prefab after.
We can create projects manually and using project wizard. Each project is with Item.cs Component fabrication. The item must be created in the scene and saved to the prefab after.

Open the Item Wizard with the toolbar at the top and press ‘Create item’ 2) Use the toolbar at the top to open the project wizard,然后按“创建项目”

Item model:
A 3d object we use as our item. Better to use single meshes
Generate collider:
Should we create a collider for an object? If object has MeshFilter you will get convex mesh as result
Add rigidbody:
Should we create rigidbody for an object?
商品型号:
We used as a project 3d 对象. It is best to use a single grid
生成碰撞器:
Should we create a collider for an object? 如果对象具有 MeshFilter,You will receive a convex grid
添加刚体:
Should we create rigid bodies for objects?

After previous step you will have new instantiated item in your scene. Our object has “Item” tag, and Item component. Your items must have “Item” tag! Otherwise pickup will not work at all. Let’s take a look at the Item component 4) 在上一步之后,There will be new instanced items in your scene. 我们的对象有“Item”标签和Item组件. Your items must be“物品”标签! Otherwise pickup doesn't work at all. 我们来看看Item组件

Pickup system
You can pickup items with special component which need to be assigned to the main camera. It’s PickupItems component. With this component you can provide interaction between player and items. The component is designed tointroduce pickup interaction by the most part and can write your own pickup methods if you need
You can pick up items with special components that need to be assigned to the main camera. This is a pickup truck project 成分. 使用此组件,You can provide interactions between players and items. Most aims to introduce the component pick up interaction,如果需要,Can write your own pick method

The component should be assigned to your player. Here you can choice interaction type. You can switch between Raycast from camera/Trigger pickup/Pickup by click. You can set pickup key with any other you want. You also need to set Player Camera field. Raycast Pickup distance controls distance for items pickup. And item name tooltip is the UI text field that we need to show item title if we looking to some item.
This component should be assigned to your player. Here you can choose the interaction type. 你可以在 By clicking on the camera/Trigger pick up/Pick up to the light casting. You can set any other pickup key you want. 您还需要设置 Player Camera 字段. Raycast Pickup distance The distance control items picked up. The project name the tool tip is UI 文本字段,If we look at an item,We need to display the item title.
Now about interaction types more close.
Now it's closer about the interaction type.
Raycast from Camera – it’s fps pickup style. You can pickup an item if you looking straight on it and distance between camera and item is equal or less to pickup distance.
Light projection from the camera - 这是 fps Pick up style. If you look straight at it and keep your distance,You can pick up it The distance between the camera and the item is equal to or less than the pickup distance.
Trigger pickup – in this case you need to have trigger collider on object that store pickup item component. After that you will able to pickup all items which in collider radius with pickup key button.
Trigger pick up - 在这种情况下,You need to trigger the collider on the object that stores the picked item component. 之后,You will be able to pick up all items within the radius of the collider using the Pickup key button.
And last one is Click to Pickup. In order to get this method work you need to assign Physics Raycaster component to your camera and also assign Touch Pickup Handler to each item prefab you have!
最后一个是 Click to Pickup. In order for this method to work,您需要将 Physics Raycaster Components assigned to your camera,并将 Touch Pickup Handler Assign to every project prefab you own!

If you’ve done everything right you can pickup items with clicking ‘em with mouse or mobile input.
如果你做的一切都正确,You can pick up items by clicking on them with mouse or movement input.
Save system
DT Inventory support items persistence. It means that you can save and load scene state for items/inventory/lootboxes. Also you can save state of the scene you enter or leave. All items will be at the same place in both cases.
DT Inventory Support items persistence. This means that you can save and load scenarios 物品/库存/战利品箱. You can also save the state as you enter or leave the scene. 在这两种情况下,All projects will be in the same location.
To make save/load work we need to assign SaveData component to your player gameobject. Also drag inventory canvas to your player. After this step you should get something familiar with the picture.
In order to make the save/加载工作,我们需要将 SaveData Component assigned to your player game object. Also drag the inventory canvas onto your player. 在这一步之后,You should know something about the picture.

Now we need to create asset database that will store all item objects of your project. To do that click right button in project view and select ‘Item database’.
Now we need to create a database to store all project assets project object. 为此,Right-click in the project view and select“项目数据库”.

Now assign each item to Items list. If you missed item, you won’t be able to restore it on load methods and SaveData script will throw exception
Now assign each item to a list of items. If you missed the program,You won't be able to restore it in the load method,and save data script will throw exception

And last step is to assign your new database to this field. Set load/save keys and hit play. Save/Load works now!
The last step is to assign your new database to this field. 设置加载/Save button and click on the play. 保存/Loading working now!
P.S. For users of DTFPS 1.4. Inventory use own Assets Database script (see on GamePrefab)
附言 对于 DTFPS 1.4 的用户. Inventory database scripts to use their own assets(参见 GamePrefab)
Persistence system
Now we can touch persistence system… For example we have 2 scenes in our project ‘Scene A’ and ‘Scene B’, and we want to keep all items that we have with their last state. We don’t want to lost our scene state when we go from ‘Scene B’ to ‘Scene A’ and want our data to be persistent.
Now we can touch the persistence system……例如,我们的项目“场景 A”和“场景 B”中有 2 个场景,We want to keep the last state of all projects.当我们从“场景 B”转到“场景 A”and want our data to persist when,We don't want to lose scene state.
First, our player gameobject must exist regardless of the current scene. Just attach DontDestroyInstance to your player and set player gameobject tag to ‘player’. Attach RegisterPlayerInstance script on player aswell. Now drag your inventroy to player hierarchy. Now your inventory and player are persistence and will not be destroyed during scene transition.
首先,No matter what the current scenario,Both our player game objects must exist.只需将 DontDestroyInstance Attach to your player and set the player game object tag to“玩家”.Additional on player RegisterPlayerInstance 脚本.Now drag your inventory into the player hierarchy.Your inventory and players are now persistent,will not be destroyed during scene transitions.
To walk between the levels you have we need to set them in build settings.
Create cube and set its collider as trigger. Attach LevelTransition script and set scene index you want to go.
To walk between the levels you have,We need to set them in the build settings.
Create a cube and set its collider as a trigger.附加 LevelTransition Script and set the scene index you want to go to.
Also we must have spawn points on the level. Create empty gameobject and attach LevelPoint script. Do it for second scene as well. Set Load Persistent Item On Scene Start if you want to leave items on the same place if you going from one level to another.
此外,We must have respawn points on the level.Create empty game object and attach LevelPoint 脚本.Do the same for the second scene.If you want to keep items in the same place when going from one level to another,Please set the scene to load persistent items to get started.

After some test iterations you will see that we still keep persistence information from other last sessions. To remove that find inventory script and press clear persistence data. It will remove all scene persistence information you have.
After some test iteration,You'll see that we still keep other last session's persistent information. Want to delete the search listing script and according to the removal of persistent data. it will delete all scene persistence information you have.

原网站

版权声明
本文为[Liu Shigang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100530293955.html