The board administrator and developer will be on vacation until the end of July. Therefore replies will be slower than usual.

Speed boots for UFPS player

altug
Posts: 3
Joined: Sun Feb 05, 2017 10:01 pm

Speed boots for UFPS player

Postby altug » Sun Jul 16, 2017 3:19 pm

I'm trying to have boots that affects UFPS's player speed. Watched and applied the script from the old tutorial video "stats and scripts" but because it was for thirdpersoncontroller and quite obsolete, I got some errors. I need to change "motorDamping" value in vp_FPController. Here is my script;

Code: Select all

using System.Collections;
using Devdog.General;
using Devdog.InventoryPro;

public class StatRunSpeed : MonoBehaviour
{

   private vp_FPController userControl;

   private InventoryPlayer inventoryPlayer;


   void Awake ()
   {

   userControl = GetComponent<vp_FPController>();
   inventoryPlayer = GetComponent<InventoryPlayer>();

   inventoryPlayer.characterCollection.OnStatChanged += CharacterCollectionOnOnStatChanged;
   }

   private void CharacterCollectionOnOnStatChanged(InventoryCharacterStat stat)
   {
      if (Stat.statName -- "Run Speed")
      {
         userControl.MotorDamping = stat.currentValue / 100;

      }

   }
}


error CS0246: The type or namespace name `InventoryCharacterStat' could not be found. Are you missing an assembly reference?
I also have definition errors for "onStatChanged" ,"InventoryCharacterStat"and "statName".

User avatar
MaximilienLoGiudice
Posts: 87
Joined: Thu Dec 08, 2016 12:50 am

Re: Speed boots for UFPS player

Postby MaximilienLoGiudice » Fri Jul 21, 2017 1:48 am

To create speed boots with Inventory pro + UFPS , i did like this :

1. in UFPS : create a new state ("walkFast") --> see doc UFPS. ( also see doc for events system )

2. in Inventory Pro : create slots, stats and items database --> see doc Inventory pro.

3. in inventory Pro : create boots item that add 30 (or any value) to speed stat.

4. Your boots should now equip in right slot and affect speed stat.

5. Create a script MyStatReader, attach it on player and use

Code: Select all

Stat_OnStatValuechanged(Istat Stat)


like this :

( this script send events to UFPS when a stat change , there is an exemple also for boots. )

Code: Select all

    private void Stats_OnStatValueChanged(IStat stat)
    {
        if (stat.definition.statName == "Level")
        {
            m_Player.LevelStatChanged.Send(_level.currentValue);
            Debug.Log("You Gained a Level ! You are now level " + _level.currentValue);
            InventoryManager.langDatabase.myCustomMessage2.Show();
            compass.ShowAnimatedText("LEVEL UP !");
        }

        if (stat.definition.statName == "Health")
        {
            m_Player.HealthStatChanged.Send(_health.currentValue);
        }

        if (stat.definition.statName == "Armor")
        {
            m_Player.ArmorStatChanged.Send(_armor.currentValue);
        }

        if (stat.definition.statName == "Shield")
        {
            m_Player.ShieldStatChanged.Send(_shield.currentValue);
        }

        if (stat.definition.statName == "Hunger")
        {
            float i = _hunger.currentValue;
            m_Player.HungerStatChanged.Send(i);
        }

        if (stat.definition.statName == "Thirst")
        {
            float i = _thirst.currentValue;
            m_Player.ThirstStatChanged.Send(i);
        }
       
        if (stat.definition.statName == "Speed")
        {
            m_Player.SpeedStatChanged.Send(_speed.currentValue);

            if (stat.currentValue == 30)
            {
                Debug.Log("JBoots Effect ON !");
                //Launching new state (i created an new state with more speed)
                fpController.SetState("WalkFast", true);
                           }
            // unwearing boots
            else if (stat.currentValue == 0)
            {
                Debug.Log("JBoots Effect OFF !");
                fpController.SetState("WalkFast", false);
            }
        }

        if (stat.definition.statName == "Intelligence")
        {
            m_Player.IntStatChanged.Send(_intell.currentValue);
        }

        if (stat.definition.statName == "Strength")
        {
            m_Player.StrStatChanged.Send(_strength.currentValue);
        }

        if (stat.definition.statName == "Dexterity")
        {
            m_Player.DexStatChanged.Send(_dexterity.currentValue);
        }

        if (stat.definition.statName == "Agility")
        {
            m_Player.AgiStatChanged.Send(_agility.currentValue);
        }

    }


I hope this will help you.

Regards.


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 2 guests