Item Manager: Difference between revisions

From Graal Bible
(Created page with "This section will go over how to add an item (gun, melee, items...) to your character.")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
This section will go over how to add an item (gun, melee, items...) to your character.
This section will go over how to create and add an item (gun, melee, items...) to your character.
 
==== Step1 ====
In the weapon: '''''3D/Player/Item/Manager'''''
 
in the '''''function onCreated()''''' and to the variable '''''this.allItems'''''  add your item using this format:
{| class="wikitable"
!{name Of Item, associated Weapon, icon Prefab for UI}
|}
[[File:ItemManager.png|frameless|917x917px]]
 
==== Step2 ====
Create the associated Weapon for the item you want to create.
 
Check '''''3D/Player/Item/Weapons/Ranged/Gun/M16''''' for example.
//#CLIENTSIDE
function onCreated() {
  this.isEquipped = false;
  this.prefabName = "M16";
  this.muzzleScale = 0.56;
  this.firerate = 0.2;
  this.bulletSpread = 1;
  this.bulletPerShot = 1;
  this.maxMagazineAmmo = 30;
  this.reloadSpeed = 2;
  this.maxRange = 14;
  this.isBow = false;
  settimer(9999);
  this.shootCD = 0;
}
function onUpdate() {
  if (this.shootCD < 0 || !this.isEquipped) return;
  this.shootCD -= Time::deltaTime;
}
public function onAction() {
  if (!this.isEquipped) {
    RANGEDBASE.equipRanged(this.prefabName, this.muzzleScale, this.firerate, this.bulletSpread, this.bulletPerShot, this.maxMagazineAmmo, this.reloadSpeed, this.maxRange, this.isBow);
    this.isEquipped = true;
  } else if (this.shootCD < 0) {
    RANGEDBASE.onShootBullet(this.bulletPerShot);
    this.shootCD = this.firerate;
  }
}
public function unEquip() {
  if (!this.isEquipped) return;
  this.isEquipped = false;
  RANGEDBASE.unEquip();
}

Latest revision as of 07:47, 8 July 2021

This section will go over how to create and add an item (gun, melee, items...) to your character.

Step1

In the weapon: 3D/Player/Item/Manager

in the function onCreated() and to the variable this.allItems add your item using this format:

{name Of Item, associated Weapon, icon Prefab for UI}

ItemManager.png

Step2

Create the associated Weapon for the item you want to create.

Check 3D/Player/Item/Weapons/Ranged/Gun/M16 for example.

//#CLIENTSIDE

function onCreated() {
  this.isEquipped = false;
  this.prefabName = "M16";
  this.muzzleScale = 0.56;
  this.firerate = 0.2;
  this.bulletSpread = 1;
  this.bulletPerShot = 1;
  this.maxMagazineAmmo = 30;
  this.reloadSpeed = 2;
  this.maxRange = 14;
  this.isBow = false;
  settimer(9999);
  this.shootCD = 0;
}

function onUpdate() {
  if (this.shootCD < 0 || !this.isEquipped) return;
  this.shootCD -= Time::deltaTime;
}

public function onAction() {
  if (!this.isEquipped) {
    RANGEDBASE.equipRanged(this.prefabName, this.muzzleScale, this.firerate, this.bulletSpread, this.bulletPerShot, this.maxMagazineAmmo, this.reloadSpeed, this.maxRange, this.isBow);
    this.isEquipped = true;
  } else if (this.shootCD < 0) {
    RANGEDBASE.onShootBullet(this.bulletPerShot);
    this.shootCD = this.firerate;
  }
}
public function unEquip() {
  if (!this.isEquipped) return;
  this.isEquipped = false;
  RANGEDBASE.unEquip();
}