Escolar Documentos
Profissional Documentos
Cultura Documentos
MANUAL
Ultimate Survival 0.1
Video tutorials will be (or already are) available at:
https://www.youtube.com/channel/UChtibaEti4OD5kylKUesn0A
Forum thread:
https://forum.unity3d.com/threads/0-1-pending-ultimate-survival-the-complete-
survival-template.442016/
E-mail support:
mailto:winterbyte312@gmail.com
2|Page
CONTENTS
AI ....................................................................................................................................... 28
A) ADDING A HUMANOID AI ............................................................................ 28
B) GROUPING THE AGENTS WITH THE AIGROUP .................................................... 30
OTHERS ........................................................................................................................... 31
A) THE INPUT WINDOW ................................................................................... 31
B) HOW TO CREATE A NEW SURFACE IN THE SURFACE DATABASE ............................... 32
3|Page
How to set up a scene
Whether you created a new scene or want to import the asset functionality into
your existing one, you need a few objects to make sure the scene will function
properly.
_Game Controller - is the central point from where you access utilities or important
variables and properties.
In-Game GUI - here you'll find all the UI systems, like the Inventory, Hotbar, Item
Inspector and many others.
Male_Player - this is the player object, through which you can play the game.
NOTE: you can add them automatically from the menu, just go to:
Tools/Ultimate Survival/Add/Base Scene Objects:
NOTE: Anything else you might need, like ambience audio, wind zones, reflection
probes, and so on, it's up to you to add and configure for your custom scene.
4|Page
How to add a new item (data only)
1. Adding the item to the database
- To create any item, go to the menu, and click on Ultimate Survival/Item Management:
- While there, you'll see the items organized by category. Choose a category, or add
your own, and then create your item in that category, just click the + button for
adding new elements.
- When you've added a new item in your desired category, click on it, you'll see all
of it's data in the Item Inspector:
5|Page
2. Explaining the item settings
Name - the item name.
Display Name - useful when you want to display the same name for 2 or more
items (eg. maybe you have 3 variations of one item).
World Object - this is the "pickup" for this item, so you can actually drop it, or pick
it up from the ground. See how to create a pickup here.[ADD LINK]
Stack Size - how many items of this type you can stack at once.
Descriptions - you can have multiple descriptions, simple items will need only one,
more complex items, like the one above (a gun), requires a second description to
describe it's properties (eg. a gun can have a Range, or a Fire Rate property, or
both).
NOTE: Multiple descriptions are useful when you want to display them in different
parts of the screen, like here:
You can clearly see if we had just one description, it'd be difficult to format it's text
like that.
NOTE: You can use Rich Text as well (HTML tags to customize the text); If you're
not familiar with it, take a look at how the other items made use of it, and visit this
page: https://docs.unity3d.com/Manual/StyledText.html
NOTE: You can also display an item property (we'll talk about them below) in the
description, to do that, you have to write the index of the property, and
surrounded by curly braces: {index}.
6|Page
Example: "Defense: {0}", "Fire Rate: {1}", "Attack Power: {2}"
And this is how it looks in the game (you can see the value of Defense being
displayed):
Properties - all the item's properties, like Defense, Durability, Health Change, and so on;
You can also define custom properties, I'll show you how to do that, below.
Is Placeable? - if enabled, it's considered the item can be placed (example would be
a furnace, or a campfire). To learn how to create a placeable object (which you can
link with an item), jump here.[LINK]
Recipe - a list with all the "ingredients" necessary to craft this item, and also how
much time it takes to craft it.
7|Page
3. Adding a new property
- To add a new property, select the Property Editor tab:
Here you can see all the existing properties; To add one, just click the + button.
- You can also choose a type for a property, because certain properties can hold
different types of values, for example:
Hunger Change - is a random number in a range (min, max), of type Random Int.
Can Dismantle - doesn't need a special type, it just needs to be attached to the item,
for that we have the None type.
8|Page
How to add a gun
a) Adding a gun from scratch
1. Adding the item data
We'll add the default assault rifle, from scratch, under the name "New Rifle":
- Go to the item management window, like you learned here
- Select the Gun category
- Select the Assault Rifle item, and hit Shift + D, to duplicate
- Rename it to "New Rifle"
- Tweak it's description, crafting recipe, and properties.
NOTE: You can now add the item to storage boxes, corpse loot, and so on.
WARNING! When we duplicated the assault rifle, the pickup from the old item got
duplicated too. The pickup is linked to this item, through the name, we have to
create a new pickup with our new name, "New Rifle".
9|Page
2. Creating the pickup
- Go to Ultimate Survival/Prefabs/Pickups/ and duplicate the Assault Rifle_Pickup object
- Rename it to "New Rifle_Pickup":
- Select the new pickup we've made, and on the ItemPickup script, change the Default
Item setting, to "New Rifle" (our new item name).
NOTE: Now when we pick up this object, the "New Rifle" item will be added to the
inventory!
- Finally, don't forget to assign this pickup, to the item's "World Object" property:
10 | P a g e
3. Adding the first-person object
NOTE: To follow the next steps, disable the "In-Game GUI" object, in the scene, to
allow you to see the gun.
- Here, create a new object called "14-New Rifle". Drag the Assault Rifle model from
the project window, into it, and call it "Model":
- Add an empty object, called "Pivot". Position it where you want the pivot of the
movement to be (movement = sway, bobbing, etc). Add the PivotDisplayer script to it,
to make it visible in the scene.
11 | P a g e
- Add the following scripts to the 14-New Rifle object (the root): AudioSource, FPHitscan,
FPMotion, FPHitscanAnimator
WARNING! By default, a new audio source is set to 2D, don't forget to set the
"Spatial Blend" to 1, that will make the source 3D.
12 | P a g e
- Expand Fire Audio, and set some fire sounds, pitch and volume
14 | P a g e
b) Explaining the gun scripts
1. FPHitscan
It's the script which handles the shooting functionality of the object.
Object Name - the object name. It is necessary this one is the same as the item name.
You'll need an item with the same name which you can have in the inventory, select
in the hotbar, etc. When that item is selected, this object will be equipped.
Target FOV - the field of view (FOV) of the first-person camera when this object is
equipped.
Use While Near Objects - can the player use this object, when he's very near to an
object, wall, etc. ?
Fire Mode - Full Auto - the gun is automatic (fires continuously). Burst - fires in bursts
(eg. in bursts of 3 shots). Semi Auto - the player has to release the attack button before
shooting again.
Max Distance - the max distance at which you can shoot with this gun.
Fire Duration - used in Semi Auto mode, the minimum time between shots.
Rounds Per Minute - used in Full Auto, how many shots can you take in a minute,
with this gun.
Ray Count - how many projectiles are in a single shot (useful for shotguns because
they need more than 1).
Normal Spread - the spread (in angles) of the projectiles, when shooting while not
aiming.
15 | P a g e
Aim Spread - the spread (in angles) of the projectiles, when shooting while aiming.
Ray Impact
Max Damage - damage per shot, when the object hit is close.
Max Impulse - the impulse applied per shot, when the object hit is close.
Distance Curve - how the damage & impulse lower over distance.
Fire Audio - the sounds, pitch, and volume of the gun when firing.
Muzzle Flash - a particle system which will be played as a flash when firing (ideally
the ParticleSystem component should have the "Lights" module enabled as well).
Tracer - the trace of a bullet / projectile.
Tracer Offset - the position offset, relative to the gun, at which the tracer is
spawned.
Shell Prefab - not all guns will require to eject a shell, but most of them do; This is
the prefab.
Shell Spawn Method - Auto - it'll be spawned automatically when the shot is taken.
On Animation Event - you have to call it with an animation event (useful for timing the
shell ejecting with the animation).
Anim Event Handler - a script which should be attached to the model (which has an
Animator component attached). It's purpose is to pick up animation events from the
animated model.
Weapon Root - the spawn offset of the shell is relative to this object.
Shell Spawn Offset - the spawn offset of the shell, relative to Weapon Root.
16 | P a g e
2. FPMotion
What I need to explain for this script, is the 3 elements used here, Sway, Bob and
Offset. You can see there are different types of them, like "Walk Bob", "Aim Bob",
etc, "Idle Offset", Run Offset, etc.
Sway - it helps the object look more dynamic, otherwise it'll look too rigid,
unrealistic; When the camera moves, the object will stay a little bit behind.
Enabled - if it's not enabled, the sway will not be applied to the movement.
Magnitude - how much it stays behind, if it's movement sway, the magnitude
is in units, if it's rotation sway, the magnitude is in angles.
Lerp Speed - the lower this is, the smoother the sway.
Bob - used for the left & right movement of the object, when walking & running.
Enabled - if it's not enabled, the bob will not be applied to the movement.
Speed - how fast is the animation.
Cooldown Speed - after this bob is not used, how fast it fades out.
Amount X, Y - the maximum translation of the bob.
Curve - control the speed of the animation at different intervals.
3. FPHitscanAnimator
Manages the actual animations (if the gun/object has them), and also the enabling
and disabling of the object.
Fire Types Count - how many fire animations this gun has? (they will be played
randomly).
17 | P a g e
How to add a tool
a) Adding a tool from scratch
1. Adding the item data
We'll add the default axe, from scratch, under the name "New Axe":
- Go to the item management window, like you learned here
- Select the Tool category
- Select Axe item, and hit Shift + D, to duplicate
- Rename it to "New Axe"
- Tweak it's description, crafting recipe, and properties.
NOTE: You can now add the item to storage boxes, corpse loot, and so on.
WARNING! When we duplicated the axe, the pickup from the old item got
duplicated too. The pickup is linked to this item, through the name, we have to
create a new pickup with our new name, "New Axe".
18 | P a g e
2. Creating the pickup
- Go to Ultimate Survival/Prefabs/Pickups/ and duplicate the Axe_Pickup object
- Rename it to "New Axe_Pickup":
- Select the new pickup we've made, and on the ItemPickup script, change the Default
Item setting, to "New Axe" (our new item name).
NOTE: Now when we pick up this object, the "New Axe" item will be added to the
inventory!
- Finally, don't forget to assign this pickup, to the item's "World Object" property:
19 | P a g e
3. Adding the first person object
NOTE: To follow the next steps, disable the "In-Game GUI" object, to allow you to
see the gun.
- Here, create a new object called "14-New Axe". Drag the Axe model from the
project, into it, and call it "Model"
20 | P a g e
- Add an empty object, called "Pivot". Position it where you want the pivot of the
movement to be (movement = sway, bobbing, etc). Add the PivotDisplayer script to it,
to make it visible in the scene.
- Add the following scripts to the 14-New Axe object (the root): AudioSource, FPTool,
FPMotion, FPMeleeAnimator
WARNING! By default, a new audio source is set to 2D, don't forget to set the
"Spatial Blend" to 1, that will make the source 3D.
21 | P a g e
On the FPTool component:
- Set Object Name to "New Axe"
- Set Use While Near Objects to true
- Assign the Event Handler (drag the Model object here)
- Set Max Reach to 1.2
- Set Time Between Attacks to 0.75
- Set Damage Per Hit to 100
- Set Impact Force to 15
- Assign the Audio Source field
- Set the attack sounds, pitch and volume
- Set the Sound Type to Chop
- Set the Tool Purposes to have 1 element, Cut Wood
22 | P a g e
To set up the procedural motion, go to the FPMotion component and:
- Assign the Model & Pivot fields
- Apply the Tool preset
- Tweak the settings to your liking. To learn more about them, go here.
23 | P a g e
IMPORTANT! The purpose of the FPMeleeEventHandler script (attached to the Model
object) is to pick up animation events. The most important event is the "Hit" event, it
is triggered when the axe/melee object looks like it's hitting another object. If you
add your own melee object, make sure to add an animation event (with the name
"On_Hit"). This is how it looks for the axe model:
24 | P a g e
Mineable objects
a) Adding a rock
Navigate to Ultimate Survival/Prefabs/Objects/Rock_Metal:
You also see other components attached, the important ones are:
Mesh Collider - you need a collider so the object is detected, it doesn't have to be a
MeshCollider, any collider will work.
Nav Mesh Obstacle - it will make the AI agents avoid this object (and not walk
through it).
25 | P a g e
b) Adding a tree
Navigate to: Ultimate Survival/Prefabs/Objects/Empty Tree:
You also see other components attached, the important one is:
* If you want to learn more, go to the Forest scene, and check the Terrain object.
26 | P a g e
c) Explanations
Let's discuss the MineableObject/Mineable Tree script settings:
Required Tool Purpose - each tool can have a "purpose", an axe should have Cut
Wood, while a pickaxe Break Rocks. This helps when you want certain tools to be
effective on certain objects (eg. you don't want to cut wood with a pickaxe).
Resistance - 0 means the incoming damage is not reduced at all (0%), 0.5 means the
damage is reduced by 50%, and so on. This is a common property found on any
object that can take damage, like the player, or a cannibal, or even a buildable
object.
Destroyed Object - when the object's health reaches 0, it will obviously "die", and
this is the object / prefab that will be spawned.
Destroyed Object Offset - the position offset of the spawned object, relative to the
mineable object.
Loot - a list with the items that can be gathered from this object.
Show Gather Message - whether or not to show a message when the player gathers
items from this object.
Loot Name Color - If you gather 5 x Stone, the message will be: "You gathered 5 x
Stone"; "Stone" will have the Loot Name Color color, and the rest of the text will have
the Message Color color.
27 | P a g e
AI
a) Adding a humanoid AI
I'll show you how to turn a Humanoid model, into a cannibal:
28 | P a g e
- Click Create, this will add all the colliders, rigidbodies & joints necessary for the
ragdoll to work.
- Expand the model, and go the armature root, usually called "Armature"
- Select it, and add a Ragdoll component
- Drag the pelvis/hips bone into the Pelvis field
- In the Surface Texture field, add your character's main texture (make sure it's set up
in the Surface Database, as a "skin" texture, so the blood effects can work)
29 | P a g e
b) Grouping the agents with the AIGroup
The AIGroup script will take care of spawning & respawning of agents.
Just scatter a few groups around the map, or create them via scripting, and they're
going to patrol and move around the group, they'll behave just like a group.
AIGroup script
Group Color - the color of the gizmos used for this group (useful for the
visualization of the group)
Make Agents Children - this will make the newly created agents, children of this
group object
Group Radius - the agents will be spawned around the group, in this radius
(randomly)
30 | P a g e
Others
a) The input window
To access the input window, go to the menu, and navigate to Ultimate Survival/Input
Window:
This window is an alternative to Unity's built-in Input window, and it has mainly
two advantages:
- You can rearrange the buttons & axes
- You can delete and add easily, at every position in the list
* So if you're familiar with Unity's way of gathering input, this is done in the same
way, by using the same methods (GetButton, GetAxis, etc).
31 | P a g e
b) How to create a new surface in the Surface Database
The surface database is a collection of surfaces. Each surface defines it's own
footsteps, bullet hits effects, decals, and so on.
Default Surface - is the surface data used, when no other surface data matches the
texture we're trying to get data for.
Surfaces - all the surfaces defined so far.
The rest of the settings are pretty self-explanatory, basically a big chunk of sounds &
effects to play in different situations.
32 | P a g e
Adding a new buildable object
A buildable object is an object which can be placed by the player, usually in sockets.
Socket = a point on a buildable, in which other buildables can be placed. (eg. a point
where walls can be placed, on a platform).
* To add new buildables to this socket (they'll snap here), just hit the + button and
drag it in here.
WARNING! When Edit Piece Offset is enabled, you can't edit the socket position &
rotation with the handles.
33 | P a g e
b) Creating a buildable from scratch
1. Creating the base object
- Drag your model in the scene
- Go to menu -> Tools/Ultimate Survival/Add/Buildable Creator
- A wizard will appear
- Drag your object from the scene, to the Model field
- Click Create.
34 | P a g e
3. Adding new sockets
- Create an empty object, call it "Socket"
- Set it's layer to "Building Piece"
- Add the Socket component
- To add a new piece offset, just hit the "+" button, and drag your pieces here.
- To modify and preview the piece, select "Edit Piece Offset"
WARNING! When you drag a piece to the socket, make sure you drag from the
project, not from the scene!
35 | P a g e
4. Configuring the Building Piece component (Important!)
This is the most important part, on the Building Piece component you edit all the
behaviours & functionality. Go back to the Building Piece component, expand it.
Let's go through each setting, and explain what it is, and how to tweak it:
Required Items - a list with all the required items in order to place this object.
Rotation Axis - on what axis should the object rotate? (when the player uses the
rotate buttons)
Bounds - make sure Show Bounds is enabled, and start editing it. Use the Scene view as
well.
Ignored Renderers & Ignored Colliders - the system will enable & disable all the
attached renderers & colliders, but will ignore the ones from those lists.
Needed Space - the space in a socket, to occupy (so you can't place 2 walls in the
same sockets, etc).
Enable TP - "Enable Terrain Protection", useful for platforms, so you can't place
them too much in the terrain. It's a box which if touched by the Terrain, you won't
be able to place it.
TP Box - here you edit the box, just like editing the bounds.
* This is how the terrain protection box is configured on the wood platform:
37 | P a g e
5. Adding a piece to the Selection Wheel
- In the scene, navigate to: In-Game GUI/Canvas/1-Windows/10-Building Menu/Window/Wheel:
* To edit the positions of the categories, go to the Wheel object, and edit the Layout
header
* To edit the position of the pieces in a category, click on a category, and edit the
Layout header.
38 | P a g e