|
Post by rbm on Jan 7, 2017 8:59:24 GMT
Hi
How can I modify Vpickable-item to add score or Counter on it?
(OR should I modify this code or make another script(component) and add to third person character?)
I want to add some things like coin - diamond - ..... and save the amount of picked items and show them on the screen !
And also make mission by them ! for example player should take 10 diamond and 10 coin!
if you give the code for counter it will be really better!\\
thanks
sorry for my bad English
|
|
|
Post by rbm on Jan 13, 2017 17:21:16 GMT
no idea?
|
|
|
Post by Chronicman on Jan 13, 2017 17:39:57 GMT
Hey rbm, First you would need to create the diamonds or coins via the vItemCreation menu and add them to your v Collectable game object. I would next create a script to monitor how many coins or diamonds are in the inventory this can be accomplished quite easy.
1) go into the vItemManager script and find the field instance and make it public this will allow us to access the Inventory from any class.
2) paste this to a new script and attach it to the collectable item and invoke the OnCollect void with the event that is on Invectors script.
3) fill in the UI update code
using System.Collections; using UnityEngine; using Invector.ItemManager;
public class myCollectableScript : MonoBehaviour { public int coinID; public int diamondID; public void OnCollect() { var CoinItem = vItemManager.instance.items.Find(_item => _item.id == coinID); if (CoinItem != null) { // update UI // set text to = CoinItem.amount } var DiamoindItem = vItemManager.instance.items.Find(_item => _item.id == diamondID); if (CoinItem != null) { // update UI // set text to = DiamoindItem.amount } } }
|
|
|
Post by rbm on Apr 20, 2017 15:56:13 GMT
I have TPS - v1.3e
and there is no vItemCreation
and also error on this line:
using Invector.ItemManager;
_________________________________________________ there is no easier way?
|
|
|
Post by dreadlord on Apr 20, 2017 17:44:31 GMT
I have TPS - v1.3eand there is no vItemCreation and also error on this line: using Invector.ItemManager; _________________________________________________ there is no easier way? Press Update :-)
|
|