How to create weapons and items
Last updated
Last updated
1- Place Item Model in Scene and Unpack Prefab
2- Set layer to "Item" layer
3- If you want use Drop System and Pick Up System, add a Collider and RigidBody
4- Add any of the components below, configure it and create the prefab by dragging it to a folder in the Project window.
In JU TPS there are some types of ready-made holdable items, they are: General Holdable Item, Weapon, Granade and Melee Weapon
All holdable items will have the essential parameters below, this means you can repeat the first steps for all holdable items
Unlocked
When checked, the item is ready to be equipped and used
Item Name
Name of how the item will appear in the inventory, it is also required for other actions such as Pick Up
Item Switch ID
Index for the Item Switch System, it is automatically set when the game starts, as the value must be according to the position in the hierarchy
Item Filter Tag
Item Icon
Icon of the Item that will appear in the inventory and in the "Current Item Information" present in the default UI templates
Item Quantity
Quantity of items, if it is 0 the item will be blocked
Item On Body
Visual 3D model of the Item on the body, it is used to distribute the items on the body when not in use, not necessary if you don't want to
Single Use Item
When used the item will be locked.
Continuous Use Item
With this option, while the use button is being pressed, the item's use function will be called at each Frame
Block Fire Mode
For items that don't need Fire Mode to work, like grenades and melee weapons, which can block Fire Mode to work properly
Hold Pose
List of poses to hold item while not in Fire Mode
Push Item From
Basically the animation of equipping the item
Item Wielding Position ID
Is Left Hand Item
This is to differentiate if the item is left hand item
Force Dual Wielding
The Item when equipped will activate the "Dual Item to Wielding" in the left hand and they will work together.
Dual Item To Wielding
Item in left hand to be activated when Item in right hand is equipped for Dual Wielding System to work.
Left Hand Position
A GameObject that stores the position and rotation of the left OR right hand wielding the item ⚠ Example: the left hand supporting the right hand on the pistol
It has no differences from the default holdable items settings other than events that you can use to call functions from code or simple actions like turning a light on and off:
The Weapon Component has some unique parameters that you will need to configure:
Accuracy
It's accuracy speed, the higher the faster the weapon will regain accuracy after a shot and the faster the crosshair on the screen will move.
Loss of Accuracy per Shot
The higher it is, the less accurate the gun will be on each shot. It is recommended to leave it at a low value (like 0.1 - 1).
Shooting Position
GameObject that keep the position where the bullet is instantiated, is also used to calculate the direction of the bullet.
Bullet Prefab
Prefab of Bullet
Muzzle Flash Prefab
Prefab of Muzzle Flash Effect
Fire Mode [ Auto, Semi Auto, Bolt Action, Shotgun ]
Auto: Machinge Guns Semi Auto: Pistols Bolt Action: Snipers Shotgun: Shotguns
Aim Mode [ Camera Aproach, Scope Texture ]
Weapon sight type
Camera Aiming Position
Camera position while aiming.
Camera FOV
Camera Aiming FOV
Fire Rate
Shooting fire rate
Bullets in the Gun
Bullets loaded in the magazine
Total Amount of Bullets
Total bullets stored of the weapon
Bullets for Reload
Number of bullets per magazine
Number of Shotgun Bullets per Shot
Number of bullet instances per shot in a shotgun
Enable
Enable procedural weapon animations.
Weapon Position Speed
Speed at which the weapon returns to its original position after a shot.
Weapon Rotation Speed
Speed at which the weapon returns to its original rotation after a shot.
Recoil Force
Force at which the gun pushes the hand back after a shot.
Recoil Rotation Force
Force at which the gun rotates the hand after a shot.
Camera Recoil Multiplier
Force that the recoil affects the direction of the camera.
Slider Movement Axis
Axis of movement of the weapon slider.
Gun Bolt/Slider
Weapon Slider GameObject
Bolt/Slider Movement
The distance the Slider will be pulled back after the shot.
Bolt/Slider Speed
Speed at which the Slider will return to its original position.
Bullet Casing
Bullet casing, can be a GameObject to instantiate or a Particle System(you have to check the option below to use Particle System)
Is Particle System
Bullet casing is a Particle System
Shot Audio
Shot Audio Clip
Reload Audio
Reload Audio Clip
Weapon Equip Audio
Equip Audio Clip
Empty Magazine Audio
No Ammo Audio Clip
Melee weapons are simple:
Attack Animator Parameter
Parameter that triggers the sequence of attacks by the JU Character animator. So far by default there are three parameters in Animator: OneHandMeleeAttack, TwoHandMeleeAttack and DualHandMeleeAttack
Enable Health Loss
Enable health to item
Health
Health value
Damage Per Use
Damager is a script that basically works to damage any GameObject with JU Health Component.
Needs a collider and a rigidbody to detect collisions.
Damage
Damage
Disable On Start
Disable GameObject on game start
Hit Min Time
Delay to hit again after a hit
Raycasting Mode
This mode does not need a collider or a non-kinematic rigidbody.
Raycast Collide With
Raycast Layer Mask
Raycast Distance
Raycast Distance
Ignore All Colliders of Root GameObject
Ignores all colliders of the root GameObject (this is to ignore the player's body colliders for example and not damage itself)
Lock Start Position
As the Damager needs a non-kinematic rigidbody to detect collisions, it is normal for it to physically move, this option locks the local position of the Damager
Tags To Damage
All tags listed here will receive damage on collision with the Damager (the object being collided needs a JU Health)
Hit Particles List
Particle and audio effects for each tag
Hit Sounds Audio Source
Audio Source to play audio clips
The Grenade Component is basically the Throwable Item Component with an explosion option:
Animation Trigger Parameter
Throw Force
Throw Force
Throw Up Force
Throw Up Force
Rotation Force
Throwed Object Rotation Force
Seconds To Destroy
Seconds to destroy after being thrown.
⚠ Set the value to 0 if you don't want the object not to be destroyed
Position To Throw
Throw Position (Pay attention to Gizmos)
Direction To Throw
Throw Direction (Pay attention to Gizmos)
Explosion Prefab
Prefab with the explosion effect
Time To Explode
Time for the grenade to explode
Time To Destroy Explosion
Time that the explosion effect will visually last
The explosion effect can be equipped with the Explosion Component which can physically simulate an explosion and deal damage to characters. It's also interesting to put the Shake One Time component in the explosion, it will do the Camera Shake effect (Make sure you have a Shaker assigned to your Camera)
You should use this when you want to differentiate between types of items, to filter what can be equipped in an . ⚠ Example: Primary Weapon, Secundary Weapon[...]
Wielding position index during FireMode (You can see IDs in )
To Enable
Gameobject to enable when using melee weapon.
When the collides, the weapon takes damage
Parameter that will be called in the JU Character animator to throw the object. ⚠ Note that throw function is called by a