- Home /
Unity Network Double Damage problem
So i'm using Unity 4 i now it is like 2 months that i have the folowing problem today i write my own dynamit script which take damage over netowrk from player when it get's exploded so when is only one client on the server the dynamit is working properly it takes the player damage but the problem comes when another player connects to the server why? because the dynamit damage get doubled for example the default dynamit damage is 45 health when another player connect to the server the damage is now 90 when anoter player connects now there are 3 connected players the damage is 135 so this is all and i have no idea what i have to do i'm so confused because this is the only problem i never had problems with networking but this is getting me very bored :/
here is the code to Dynamit
using UnityEngine;
using System.Collections;
public class DynamitExplode : MonoBehaviour {
public float damage = 45;
public bool canExplode = true;
public bool explodeNow = false;
public GameObject particles;
public float timer = 6;
public float counter = 0;
void Start () {
}
// Update is called once per frame
void Update () {
if(Network.isServer)
{
if(canExplode)
{
counter += Time.deltaTime;
}
if(explodeNow)
{
Network.Instantiate(particles, transform.position, transform.rotation, 0);
Network.Destroy(gameObject);
}
if(counter > timer)
{
explodeNow = true;
}
}
}
void OnTriggerStay(Collider col)
{
if(explodeNow)
{
if(col.gameObject.tag == "Player")
{
col.networkView.RPC("DynamitHit", RPCMode.All, damage);
}
}
}
}
So please is there anybody who can help me with this i will appreciate any help from you thanks :) PS: sorry for bad language :/
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Best cross platform Http Library? 1 Answer
Non-dedicated server? 1 Answer
Save and Load JSON Data to and from Webserver, Performance Question 0 Answers