Add photon for damage
Options
Haskoman
✭
Hello all i need our help
player local have damage hunger, but player connecte don receive damage help me please add photon view
player local have damage hunger, but player connecte don receive damage help me please add photon view
using UnityEngine; using System.Collections; using UnityEngine.EventSystems; using System.Collections.Generic; using System.Linq.Expressions; using System; using System.Linq; using Devdog.InventorySystem; using Devdog.InventorySystem.Models; using Devdog.InventorySystem.UI; using UnityEngine.Assertions; using UnityEngine.SceneManagement; using UnityEngine.UI; public class Hunger : Photon.MonoBehaviour { public CharacterUI characterUI; // Assign in the inspector public vp_FPPlayerDamageHandler playerDamageScript;// Assign in the inspector public vp_FPPlayerDamageHandler script;// Assign in the inspector public vp_PlayerRespawner spawn; public float foodDamageAmount; public float checkFood = 10; //How often the script checks the food value. This also is how often the player is damaged when the food is 10 or below public float checkFoodTimer = 0; private WaitForSeconds waitTime; public IInventoryCharacterStat hungerStat; public void Update() { hungerStat = characterUI.stats.Get("Default", "Hunger"); waitTime = new WaitForSeconds(1f); // Create once to avoid GC StartCoroutine(DegradeHungerOverTime()); checkFoodTimer += Time.deltaTime; // Start Food Timer } protected IEnumerator DegradeHungerOverTime() { yield return waitTime; // Decrease stamina by 1 every second. This will auto. repaint any UI that displays this stat. hungerStat.ChangeCurrentValueRaw(-0.1f); if (checkFoodTimer >= checkFood && hungerStat.currentValue <= 10) //Check food value has reached 10 { playerDamageScript.Damage(foodDamageAmount); //Damage Player if (script.CurrentHealth <= 0) // if check health { script.Die(); Debug.Log("Die = " + spawn); SceneManager.LoadScene("SosSurvival1"); } } } }
0
Comments
-
help me please ;(0
-
photonView.RPC("playerDamageScript)", PhotonTargets.All, playerDamageScript, PhotonNetwork.player);
but health dond down ;(0 -
no help ;(0
-
Please be patient and try to help yourself in the mean time.
RPC problems often go away after implementing them according to our tutorials:
https://doc.photonengine.com/en-us/pun/current/tutorials/pun-basics-tutorial/intro
and
https://doc.photonengine.com/en-us/pun/current/tutorials/tutorial-marco-polo
Let us know if you found a solution and maybe we can take a look next week.0