photon broken.

Options
(redoing post again because CLEARLY nobody is awnsering to my past post)

i have 4 bugs.
first character animation is bugged in a weird way, i can move in the build but my friends player model decides to go to move forward animation when im moving or copy my animations when im moving, when my friends moving he has no animation (just idle animation) and then to him he sees my player model animation doing the exact same thing like it happened to him.

second bug, weapons wont do anything, knife and weapons wont do anything, the gun wont change or shoot in the game, like first person can shoot but player model has the guns in it and has a script called WeaponSync.cs and it not doing anything, i cant even kill with rpg, grenade and grenade launcher.

third bug player FallDamage is not doing anything, when i fall from a great high in game i suppost to die and spawn broken legs ragdoll but instead it does no damage, only sound, theres no bloody screen, just fall sound, but with explosive damage it doesnt do anything too, with bone damage i get only this error PhotonView with ID 1001 has no method "BoneDamage" marked with the [PunRPC](C#) or @PunRPC(JS) property!, even tho im using PunRPC and not RPC.

forth bug. character skin is not working correctly, my cloth skin is all black when it suppost to be green

Scripts:

Player damage (Shows parts only of the damage not doing anything)

public void ExplosiveDamage(float explosiveDamage)
{

GetComponent().clip = RPGHIT;
GetComponent().Play();
if (disableDamage)
return;
fadeValue = 2;
photonView.RPC("ApplyRocketDamage", PhotonTargets.All, explosiveDamage, PhotonNetwork.player);
}

[PunRPC]
//This is damage sent fro remote player instance to our local
void DoRpgDamage(float explosiveDamage, PhotonPlayer player)
{
if (weKilled)
return;
if (currentHp > 0 && photonView.isMine)
{
this.StopAllCoroutines();
StartCoroutine(doCameraShake());
}

fadeValueB = 2;
currentHp -= explosiveDamage;

//We got killed
if (currentHp < 0)
{
//Deactivate all child meshes
for (int i = 0; i < transform.childCount; i++)
{
transform.GetChild(i).gameObject.SetActive(false);




}

//Spawn ragdoll
GameObject temp;
temp = Instantiate(goryRagdoll, transform.position, transform.rotation) as GameObject;

if (!photonView.isMine)
{
temp.SendMessage("clearCamera");

if (PhotonNetwork.player == player)
{
//Send death notification message to script WhoKilledWho.cs
networkObject.SendMessage("AddKillNotification", gameObject.name, SendMessageOptions.DontRequireReceiver);

//Add team score
int teamScore = new int();
if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_1.teamName)
{



//Add 1 kill for our player
int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"];
totalKIlls++;
Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } };
PhotonNetwork.player.SetCustomProperties(setPlayerKills);

}

if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_2.teamName)
{


teamScore = (int)PhotonNetwork.room.customProperties["Team1Score"];
teamScore--;
Hashtable setTeam1Score = new Hashtable() { { "Team1Score", teamScore } };
PhotonNetwork.room.SetCustomProperties(setTeam1Score);



//Add 1 kill for our player
int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"];
totalKIlls++;
Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } };
PhotonNetwork.player.SetCustomProperties(setPlayerKills);

}
}
}
else
{
//print ("We got killed");
temp.SendMessage("RespawnAfter");

//We was killed, add 1 to deaths
int totalDeaths = (int)PhotonNetwork.player.customProperties["Deaths"];
totalDeaths ++;
Hashtable setPlayerDeaths = new Hashtable() { { "Deaths", totalDeaths } };
PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);
//Destroy our player
StartCoroutine(DestroyPlayer(0.2f));

if (PhotonNetwork.player == player)
{
//Our player fell down
networkObject.SendMessage("PlayerFellDown", PhotonNetwork.player.name, SendMessageOptions.DontRequireReceiver);
teamLives = (int)PhotonNetwork.room.customProperties["Team1Score"];
teamLives--;
Hashtable setTeam1Score_fell = new Hashtable() { { "Team1Score", teamLives } };
PhotonNetwork.room.SetCustomProperties(setTeam1Score_fell);

}

}
currentHp = 0;
weKilled = true;

}
}

Comments

  • Weapon Sync.

    using System.Collections;
    using UnityEngine;

    [RequireComponent(typeof(AudioSource))]
    public class WeaponSync : MonoBehaviour
    {
    public WeaponScript firstPersonWeapon;

    public Transform firePoint;

    public GameObject bullet;

    public Renderer muzzleFlash;

    public Rigidbody projectile;

    public AudioClip fireAudio;

    private void Start()
    {
    if ((bool)muzzleFlash)
    {
    muzzleFlash.GetComponent().enabled = false;
    }
    GetComponent().playOnAwake = false;
    if (!firstPersonWeapon)
    {
    return;
    }
    if (firstPersonWeapon.GunType == WeaponScript.gunType.MACHINE_GUN)
    {
    if ((bool)firstPersonWeapon.machineGun.bullet)
    {
    bullet = firstPersonWeapon.machineGun.bullet.gameObject;
    }
    if ((bool)firstPersonWeapon.machineGun.fireSound)
    {
    fireAudio = firstPersonWeapon.machineGun.fireSound;
    }
    }
    if (firstPersonWeapon.GunType == WeaponScript.gunType.SHOTGUN)
    {
    if ((bool)firstPersonWeapon.ShotGun.bullet)
    {
    bullet = firstPersonWeapon.ShotGun.bullet.gameObject;
    }
    if ((bool)firstPersonWeapon.ShotGun.fireSound)
    {
    fireAudio = firstPersonWeapon.ShotGun.fireSound;
    }
    }
    if (firstPersonWeapon.GunType == WeaponScript.gunType.GRENADE_LAUNCHER)
    {
    if ((bool)firstPersonWeapon.grenadeLauncher.projectile)
    {
    projectile = firstPersonWeapon.grenadeLauncher.projectile;
    }
    if ((bool)firstPersonWeapon.grenadeLauncher.fireSound)
    {
    fireAudio = firstPersonWeapon.grenadeLauncher.fireSound;
    }
    }
    if (firstPersonWeapon.GunType == WeaponScript.gunType.KNIFE && (bool)firstPersonWeapon.knife.fireSound)
    {
    fireAudio = firstPersonWeapon.knife.fireSound;
    }
    }

    private void syncMachineGun(float errorAngle)
    {
    StopAllCoroutines();
    StartCoroutine(machineGunShot(errorAngle));
    }

    private IEnumerator machineGunShot(float errorAngle)
    {
    Quaternion oldRotation = firePoint.rotation;
    firePoint.rotation = Quaternion.Euler(UnityEngine.Random.insideUnitSphere * errorAngle) * firePoint.rotation;
    GameObject instantiatedBullet = UnityEngine.Object.Instantiate(bullet, firePoint.position, firePoint.rotation);
    instantiatedBullet.GetComponent().doDamage = false;
    firePoint.rotation = oldRotation;
    GetComponent().clip = fireAudio;
    GetComponent().Play();
    if ((bool)muzzleFlash)
    {
    muzzleFlash.GetComponent().enabled = true;
    yield return new WaitForSeconds(0.04f);
    muzzleFlash.GetComponent().enabled = false;
    }
    }

    private void syncShotGun(float fractions)
    {
    StopAllCoroutines();
    StartCoroutine(shotGunShot(fractions));
    }

    private IEnumerator shotGunShot(float fractions)
    {
    for (int i = 0; i < (int)fractions; i++)
    {
    Quaternion rotation = firePoint.rotation;
    firePoint.rotation = Quaternion.Euler(UnityEngine.Random.insideUnitSphere * 3f) * firePoint.rotation;
    GameObject gameObject = UnityEngine.Object.Instantiate(bullet, firePoint.position, firePoint.rotation);
    gameObject.GetComponent().doDamage = false;
    firePoint.rotation = rotation;
    }
    GetComponent().clip = fireAudio;
    GetComponent().Play();
    if ((bool)muzzleFlash)
    {
    muzzleFlash.GetComponent().enabled = true;
    yield return new WaitForSeconds(0.04f);
    muzzleFlash.GetComponent().enabled = false;
    }
    }

    private void syncGrenadeLauncher(float initialSpeed)
    {
    grenadeLauncherShot(initialSpeed);
    }

    private void grenadeLauncherShot(float initialSpeed)
    {
    Rigidbody rigidbody = UnityEngine.Object.Instantiate(projectile, firePoint.position, firePoint.rotation);
    rigidbody.GetComponent().isRemote = true;
    rigidbody.AddForce(rigidbody.transform.forward * initialSpeed * 50f);
    Physics.IgnoreCollision(rigidbody.GetComponent(), base.transform.root.GetComponent());
    Collider[] componentsInChildren = base.transform.root.GetComponentsInChildren();
    foreach (Collider collider in componentsInChildren)
    {
    Physics.IgnoreCollision(rigidbody.GetComponent(), collider);
    }
    GetComponent().clip = fireAudio;
    GetComponent().Play();
    }

    private void syncKnife(float temp)
    {
    knifeOneHit();
    }

    private void knifeOneHit()
    {
    GetComponent().clip = fireAudio;
    GetComponent().Play();
    }
    }
  • Explosion Damage

    //NSdesignGames @ 2012 - 2014
    //FPS Kit | Version 2.0

    using UnityEngine;
    using System.Collections;

    public class ExplosionDamage : MonoBehaviour {
    public float explosionRadius = 5.0f;
    public float explosionPower = 10.0f;
    public float explosionDamage = 100.0f;
    public float explosionTimeout = 2.0f;
    GameObject player1;
    [HideInInspector]
    public bool isRemote; //If explosion is remote do not deal any damage

    IEnumerator Start () {
    Vector3 explosionPosition = transform.position;

    // Apply damage to close by objects first
    Collider[] colliders = Physics.OverlapSphere (explosionPosition, explosionRadius);
    foreach (Collider hit in colliders) {
    // Calculate distance from the explosion position to the closest point on the collider
    Vector3 closestPoint = hit.ClosestPointOnBounds(explosionPosition);
    float distance = Vector3.Distance(closestPoint, explosionPosition);

    // The hit points we apply fall decrease with distance from the explosion point
    float hitPoints = 1.0f - Mathf.Clamp01(distance / explosionRadius);
    hitPoints *= explosionDamage;

    // Tell the rigidbody or any other script attached to the hit object how much damage is to be applied!
    if(!isRemote){
    hit.SendMessageUpwards("ApplyRocketDamage", hitPoints, SendMessageOptions.DontRequireReceiver);
    }
    }

    // Apply explosion forzces to all rigidbodies
    // This needs to be in two steps for ragdolls to work correctly.
    // (Enemies are first turned into ragdolls with ApplyDamage then we apply forces to all the spawned body parts)
    colliders = Physics.OverlapSphere (explosionPosition, explosionRadius);
    foreach (Collider hit in colliders) {
    if (hit.GetComponent()){
    hit.GetComponent().AddExplosionForce(explosionPower, explosionPosition, explosionRadius, 3.0f);
    }
    }

    // stop emitting particles
    if (GetComponent() ) {
    GetComponent() .emit = true;
    yield return new WaitForSeconds(0.5f);
    GetComponent() .emit = false;
    }

    Destroy (gameObject, explosionTimeout);
    }
    }
  • Character animation.

    using System;
    using System.Collections.Generic;
    using UnityEngine;

    public class CharacterAnimation : MonoBehaviour
    {
    public enum Action
    {
    Stand,
    Crouch,
    Prone
    }

    [Serializable]
    public class animations
    {
    public AnimationClip jumpPose;

    public AnimationClip stayIdle;

    public AnimationClip crouchIdle;

    public AnimationClip proneIdle;

    public AnimationClip walkFront;

    public AnimationClip walkBack;

    public AnimationClip walkLeft;

    public AnimationClip walkRight;

    public AnimationClip runFront;

    public AnimationClip crouchFront;

    public AnimationClip crouchLeft;

    public AnimationClip crouchRight;

    public AnimationClip crouchBack;

    public AnimationClip proneFront;

    public AnimationClip proneLeft;

    public AnimationClip proneRight;

    public AnimationClip proneBack;

    public AnimationClip pistolIdle;

    public AnimationClip knifeIdle;

    public AnimationClip gunIdle;
    }

    [HideInInspector]
    public string animationSyncHelper;

    [HideInInspector]
    public string animationForHands;

    [HideInInspector]
    public string activeWeapon;

    [HideInInspector]
    public string animationType;

    public WeaponManager weaponManager;

    private Action action;

    public animations Animations;

    public List twoHandedWeapons = new List();

    public List pistols = new List();

    public List knivesNades = new List();

    private FPScontroller fpsController;

    private void Start()
    {
    fpsController = base.transform.root.GetComponent();
    configureAnimations();
    if ((bool)weaponManager)
    {
    ThirdPersonWeaponControl();
    }
    }

  • private void LateUpdate()
    {
    if ((bool)weaponManager.SelectedWeapon)
    {
    activeWeapon = weaponManager.SelectedWeapon.weaponName;
    }
    if (!fpsController.crouch && !fpsController.prone)
    {
    action = Action.Stand;
    }
    else
    {
    if (fpsController.crouch && !fpsController.prone)
    {
    action = Action.Crouch;
    }
    if (!fpsController.crouch && fpsController.prone)
    {
    action = Action.Prone;
    }
    if (fpsController.crouch && fpsController.prone)
    {
    action = Action.Crouch;
    }
    }
    if (action == Action.Stand)
    {
    if (fpsController.grounded)
    {
    if (fpsController.Walking)
    {
    if (!fpsController.Running)
    {
    animationType = "Walking";
    if (UnityEngine.Input.GetKey(KeyCode.W))
    {
    GetComponent().CrossFade(Animations.walkFront.name, 0.2f);
    animationSyncHelper = Animations.walkFront.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.walkLeft.name, 0.2f);
    animationSyncHelper = Animations.walkLeft.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.walkRight.name, 0.2f);
    animationSyncHelper = Animations.walkRight.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.walkBack.name, 0.2f);
    animationSyncHelper = Animations.walkBack.name;
    }
    }
    else
    {
    animationType = "Running";
    if (UnityEngine.Input.GetKey(KeyCode.W))
    {
    GetComponent().CrossFade(Animations.runFront.name, 0.2f);
    animationSyncHelper = Animations.runFront.name;
    }
    }
    }
    else
    {
    GetComponent().CrossFade(Animations.stayIdle.name, 0.2f);
    animationSyncHelper = Animations.stayIdle.name;
    }
    }
    else
    {
    GetComponent().CrossFade(Animations.jumpPose.name, 0.2f);
    animationSyncHelper = Animations.jumpPose.name;
    }
    }
    if (action == Action.Crouch)
    {
    animationType = "Crouch";
    if (fpsController.Walking)
    {
    if (UnityEngine.Input.GetKey(KeyCode.W))
    {
    GetComponent().CrossFade(Animations.crouchFront.name, 0.2f);
    animationSyncHelper = Animations.crouchFront.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.crouchLeft.name, 0.2f);
    animationSyncHelper = Animations.crouchLeft.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.crouchRight.name, 0.2f);
    animationSyncHelper = Animations.crouchRight.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.crouchBack.name, 0.2f);
    animationSyncHelper = Animations.crouchBack.name;
    }
    }
    else
    {
    GetComponent().CrossFade(Animations.crouchIdle.name, 0.2f);
    animationSyncHelper = Animations.crouchIdle.name;
    }
    }
    if (action == Action.Prone)
    {
    animationType = "Prone";
    if (fpsController.Walking)
    {
    if (UnityEngine.Input.GetKey(KeyCode.W))
    {
    GetComponent().CrossFade(Animations.proneFront.name, 0.2f);
    animationSyncHelper = Animations.proneFront.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.proneLeft.name, 0.2f);
    animationSyncHelper = Animations.proneLeft.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.proneRight.name, 0.2f);
    animationSyncHelper = Animations.proneRight.name;
    }
    else if (UnityEngine.Input.GetKey(KeyCode.S))
    {
    GetComponent().CrossFade(Animations.proneBack.name, 0.2f);
    animationSyncHelper = Animations.proneBack.name;
    }
    }
    else
    {
    GetComponent().CrossFade(Animations.proneIdle.name, 0.2f);
    animationSyncHelper = Animations.proneIdle.name;
    }
    }
    ThirdPersonWeaponControl();
    }

    private void ThirdPersonWeaponControl()
    {
    if (action != Action.Prone)
    {
    if (twoHandedWeapons.Contains(weaponManager.SelectedWeapon))
    {
    animationForHands = Animations.gunIdle.name;
    }
    else if (pistols.Contains(weaponManager.SelectedWeapon))
    {
    animationForHands = Animations.pistolIdle.name;
    }
    else if (knivesNades.Contains(weaponManager.SelectedWeapon))
    {
    animationForHands = Animations.knifeIdle.name;
    }
    }
    else
    {
    animationForHands = "Null";
    }
    }

    private void configureAnimations()
    {
    if ((bool)Animations.stayIdle)
    {
    GetComponent()[Animations.stayIdle.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.crouchIdle)
    {
    GetComponent()[Animations.crouchIdle.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.proneIdle)
    {
    GetComponent()[Animations.proneIdle.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.walkFront)
    {
    GetComponent()[Animations.walkFront.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.walkBack)
    {
    GetComponent()[Animations.walkBack.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.walkLeft)
    {
    GetComponent()[Animations.walkLeft.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.walkRight)
    {
    GetComponent()[Animations.walkRight.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.runFront)
    {
    GetComponent()[Animations.runFront.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.crouchFront)
    {
    GetComponent()[Animations.crouchFront.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.crouchLeft)
    {
    GetComponent()[Animations.crouchLeft.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.crouchRight)
    {
    GetComponent()[Animations.crouchRight.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.crouchBack)
    {
    GetComponent()[Animations.crouchBack.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.proneFront)
    {
    GetComponent()[Animations.proneFront.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.proneLeft)
    {
    GetComponent()[Animations.proneLeft.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.proneRight)
    {
    GetComponent()[Animations.proneRight.name].wrapMode = WrapMode.Loop;
    }
    if ((bool)Animations.proneBack)
    {
    GetComponent()[Animations.proneBack.name].wrapMode = WrapMode.Loop;
    }
    }
    }
  • https://www.youtube.com/watch?v=NKB4IxHy6E8 The bugs shown in this video (I had two unitys open in the same project)
  • Tobias
    Options
    I'm sorry to read you are running into bugs. However, please be patient when you post for help. We can not debug a lot of projects ourselves, as this is time consuming. Also note: While you may work on this on the weekend, we don't. Obviously, this means replies may take even longer.

    If you post code, please wrap it in "code" blocks. The editor in this forum has buttons for that.
    The way it's posted now, we can only ignore this.


    About your issues:
    Overall, you post a lot of very project specific issues, which are very likely problems in your own code. If you post this as "bug report", almost no one can help. It's your game and code. Everyone is busy.
    In contrast, if you ask questions on how to get things accomplished (in general), you may get some response. It's better to look out for tutorials that do what you want to achieve.



    first character animation is bugged in a weird way, i can move in the build but my friends player model decides to go to move forward animation when im moving or copy my animations when im moving, when my friends moving he has no animation (just idle animation) and then to him he sees my player model animation doing the exact same thing like it happened to him.


    If the wrong character is moving, all instanced controllers react to input.
    The PhotonView component provides a IsMine value, which helps decide if any networked object should react to the input on some machine.

    I recommend reading and actually coding the Basics Tutorial as described. It should help understand some concepts needed to control only some of the characters, while showing remote characters correctly.

    https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro



    weapons wont do anything, knife and weapons wont do anything, the gun wont change or shoot in the game, like first person can shoot but player model has the guns in it and has a script called WeaponSync.cs and it not doing anything, i cant even kill with rpg, grenade and grenade launcher.


    This doc page may help:
    https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state

    I can also recommend Opsive's "UFPS" package in the Asset Store, combined with the PUN addon. It's on sale right now and solves a lot of the problems you now struggle with. Of course, only if you want to focus on making the game. If you are down to learn how this is done, read the linked doc and experiment.



    third bug player FallDamage is not doing anything, when i fall from a great high


    Sorry, can't help with this specific code. See above (point about tutorials).


    forth bug. character skin is not working correctly, my cloth skin is all black when it suppost to be green


    Same. Did you program how the skin is applied?
  • Federico123
    edited December 2019
    Options
    Tobias said:

    I'm sorry to read you are running into bugs. However, please be patient when you post for help. We can not debug a lot of projects ourselves, as this is time consuming. Also note: While you may work on this on the weekend, we don't. Obviously, this means replies may take even longer.

    If you post code, please wrap it in "code" blocks. The editor in this forum has buttons for that.
    The way it's posted now, we can only ignore this.


    About your issues:
    Overall, you post a lot of very project specific issues, which are very likely problems in your own code. If you post this as "bug report", almost no one can help. It's your game and code. Everyone is busy.
    In contrast, if you ask questions on how to get things accomplished (in general), you may get some response. It's better to look out for tutorials that do what you want to achieve.



    first character animation is bugged in a weird way, i can move in the build but my friends player model decides to go to move forward animation when im moving or copy my animations when im moving, when my friends moving he has no animation (just idle animation) and then to him he sees my player model animation doing the exact same thing like it happened to him.


    If the wrong character is moving, all instanced controllers react to input.
    The PhotonView component provides a IsMine value, which helps decide if any networked object should react to the input on some machine.

    I recommend reading and actually coding the Basics Tutorial as described. It should help understand some concepts needed to control only some of the characters, while showing remote characters correctly.

    https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro



    weapons wont do anything, knife and weapons wont do anything, the gun wont change or shoot in the game, like first person can shoot but player model has the guns in it and has a script called WeaponSync.cs and it not doing anything, i cant even kill with rpg, grenade and grenade launcher.


    This doc page may help:
    https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state

    I can also recommend Opsive's "UFPS" package in the Asset Store, combined with the PUN addon. It's on sale right now and solves a lot of the problems you now struggle with. Of course, only if you want to focus on making the game. If you are down to learn how this is done, read the linked doc and experiment.



    third bug player FallDamage is not doing anything, when i fall from a great high


    Sorry, can't help with this specific code. See above (point about tutorials).


    forth bug. character skin is not working correctly, my cloth skin is all black when it suppost to be green


    Same. Did you program how the skin is applied?
    Thanks for noticing, First, When i was trying to put the code it wouldnt be ok but it would be more bugged and nothing would be understandable, The character animation script wasnt changed since last year, I've made a game called sgp3, I still use the same scripts, I upgraded photon and i dont know of its the script fault or photons fault, I Only see the jumping animation working (rarely) sometimes, Player damage wont get work with explosive damage and bone damage, character skin does work now but not really really fine, It like works only local because to me i have the color green and my ragdoll is green but my friend cloth is orange but when he joins me i see his cloth color black and he sees my color cloth black, cant manage to get it working, Weapon sync, It's working because the guns of the names werent the same as the first person guns. (kinda works sometimes)
  • My previous game which i still use the same scripts didnt never behaved like this
  • Tobias
    Options
    Did you upgrade from PUN 1 to PUN 2? Then a few things are different enough to not run out of the box:
    https://doc.photonengine.com/en-us/pun/v2/getting-started/migration-notes
  • Federico123
    edited December 2019
    Options
    Tobias said:

    Did you upgrade from PUN 1 to PUN 2? Then a few things are different enough to not run out of the box:
    https://doc.photonengine.com/en-us/pun/v2/getting-started/migration-notes

    No i did not upgrade to PUN 2, I am still using PUN 1, Never touched PUN 2.
  • Tobias said:

    Did you upgrade from PUN 1 to PUN 2? Then a few things are different enough to not run out of the box:
    https://doc.photonengine.com/en-us/pun/v2/getting-started/migration-notes

    Also I never changed anything to multiplayer scripts, Just 4 months and i dont know if i updated photon and already a bit broken
  • Tobias
    Options
    Hmm. Hard to say then. Sorry.
  • Update, Character animation and weapon sync and sync costumization scripts are fixed, expect player damage where i cant get rpg damage or bone damage

  • Tobias wrote: »
    Hmm. Hard to say then. Sorry.

    Ok lol i know its been 1 month and its 2020 but i just put weapon messages and now the code works only DoDamage because i put this

    Now
    [PunRPC]
    	void DoDamage(float damage, string weapon, string message, PhotonPlayer player){
    

    Before
    [PunRPC]
    	void DoDamage(float damage, PhotonPlayer player)
    
  • It only happens when i fall.
    public void ApplyFallDamage(float damage)
    	{
    		if (photonView.isMine)
    		{
    			photonView.RPC("DoDamage", PhotonTargets.All, damage, PhotonNetwork.player);
    		}
    	}
    
        public void TotalDamage(float damage, string weapon, string message){
                if(disableDamage)
                    return;
                fadeValue = 2;
                 photonView.RPC("DoDamage", PhotonTargets.All, damage, weapon, message, PhotonNetwork.player);
        }
    
  • Heres the full part of DoDamage, By the way i can still play, If i try to go to a kill zone or fall i wont get any damage or i wont die.
    [PunRPC]
        void DoDamage(float damage, string weapon, string message, PhotonPlayer player){
    	{
    		if (weKilled)
    			return;
    		if (currentHp > 0 && photonView.isMine)
    		{
    			this.StopAllCoroutines();
    			StartCoroutine(doCameraShake());
    		}
    
    		fadeValueB = 2;
    		currentHp -= damage;
    
    		if (currentHp < 0)
    		{
    			for (int i = 0; i < transform.childCount; i++)
    			{
    				transform.GetChild(i).gameObject.SetActive(false);
    
    
    
    
    			}
    
    			GameObject temp;
    			temp = Instantiate(ragdoll, transform.position, transform.rotation) as GameObject;
    
    			if (!photonView.isMine)
    			{
    				temp.SendMessage("clearCamera");
    				
    				    if(!photonView.isMine){
                        temp.SendMessage("clearCamera");  
                        weapon += message;
    
    				if (PhotonNetwork.player == player)
    				{
    					networkObject.SendMessage("AddKillNotification", gameObject.name + "(" + weapon + ")", SendMessageOptions.DontRequireReceiver);
    
    					int teamScore = new int();
    					if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_a.teamName)
    					{
    						int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"];
    						totalKIlls++;
    						Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } };
    						PhotonNetwork.player.SetCustomProperties(setPlayerKills);
    
    					}
    
    					if ((string)PhotonNetwork.player.customProperties["TeamName"] == rmm.team_b.teamName)
    					{
    						teamScore = (int)PhotonNetwork.room.customProperties["Team1Score"];
    						teamScore--;
    						Hashtable setTeam1Score = new Hashtable() { { "Team1Score", teamScore } };
    						PhotonNetwork.room.SetCustomProperties(setTeam1Score);
    
    
    
    						int totalKIlls = (int)PhotonNetwork.player.customProperties["Kills"];
    						totalKIlls++;
    						Hashtable setPlayerKills = new Hashtable() { { "Kills", totalKIlls } };
    						PhotonNetwork.player.SetCustomProperties(setPlayerKills);
    
    					}
    				}
    			}
    			else
    			{
    				temp.SendMessage("RespawnAfter");
    				int totalDeaths = (int)PhotonNetwork.player.customProperties["Deaths"];
    				totalDeaths ++;
    				Hashtable setPlayerDeaths = new Hashtable() { { "Deaths", totalDeaths } };
    				PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);
    				StartCoroutine(DestroyPlayer(0.2f));
    
    				if (PhotonNetwork.player == player)
    				{
    					networkObject.SendMessage("PlayerFellDown", PhotonNetwork.player.name, SendMessageOptions.DontRequireReceiver);
    					teamLives = (int)PhotonNetwork.room.customProperties["Team1Score"];
    					teamLives--;
    					Hashtable setTeam1Score_fell = new Hashtable() { { "Team1Score", teamLives } };
    					PhotonNetwork.room.SetCustomProperties(setTeam1Score_fell);
    
    				}
    
    			}
    			currentHp = 0;
    			weKilled = true;
    			}
    		}
    	}
    }
    
  • Tobias
    Options
    Sorry but it's really tricky to debug code without the project and some context. Also, time is limited here.

    So .. any progress? Is there anything that could help us help you?
  • Tobias wrote: »
    Sorry but it's really tricky to debug code without the project and some context. Also, time is limited here.

    So .. any progress? Is there anything that could help us help you?

    What do you mean with project, do i have to put my whole project here?
  • Also heres the full error.

    PhotonView with ID 1037 has no method "DoDamage" that takes 2 argument(s): Single, PhotonPlayer
    UnityEngine.Debug:LogError(Object)
    NetworkingPeer:ExecuteRpc(Hashtable, Int32) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3136)
    NetworkingPeer:RPC(PhotonView, String, PhotonTargets, PhotonPlayer, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3898)
    PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2934)
    PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:597)
    PlayerDamage:ApplyFallDamage(Single) (at Assets/_Scripts/important scripts/PlayerDamage.cs:82)
    UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
    KillZone:OnTriggerEnter(Collider) (at Assets/_Scripts/important scripts/KillZone.cs:10)

  • Happens everytime i fall or enter a killzone which i should get killed.

    :|
  • If you want, I can make another project, put the scripts in there and the player and you can see the bug.
  • I cannot still fix it.
  • I think there is a problem with whokilledwho.

    I will check because whokilledwho needs playerdamage to show the death message
  • Hello??
  • S_Oliver
    Options

    Hello, he already said be patient.
    Could you break down your problem so I dont have to read everything.
    Also pls provide some error messages and post you code using bbCode or pastebin.com

  • S_Oliver
    S_Oliver ✭✭✭
    Options
    If i understand it right. You are using 2 x different DoDamage. I guess that could be a problem. You should rename one method. Also you dont have to send the PhotonPlayer.
    Each rpc send MessageInfo that contains the sender.
    [PunRPC]
    	private void RegularRPC(int amount, PhotonMessageInfo info)
    	{
    		var sender = info.Sender;
    	}
    
  • Tobias
    Options
    I think this is a problem due to our usage of a parameter[] in RPC() and overloading the method which should be called as PunRPC.

    Yes, I would also recommend to rename one of the two DoDamage variants.

    And yes, you don't have to send the PhotonPlayer, who is doing the damage. As @S_Oliver points out (thanks by the way), this is in the PhotonMessageInfo already.
  • Federico123
    Options
    S_Oliver wrote: »
    If i understand it right. You are using 2 x different DoDamage. I guess that could be a problem. You should rename one method. Also you dont have to send the PhotonPlayer.
    Each rpc send MessageInfo that contains the sender.
    [PunRPC]
    	private void RegularRPC(int amount, PhotonMessageInfo info)
    	{
    		var sender = info.Sender;
    	}
    

    This error happened tons of times, when i was trying to do explosion damage or fall damage (which i scrapped and made both of them use DoDamage) so there could have been different gore per deaths.
    Anyways i have made a new post which is not about player damage cause i removed the rpg damage or how the player got killed message and its about syncing problems now
  • Federico123
    Options
    S_Oliver wrote: »
    If i understand it right. You are using 2 x different DoDamage. I guess that could be a problem. You should rename one method. Also you dont have to send the PhotonPlayer.
    Each rpc send MessageInfo that contains the sender.
    [PunRPC]
    	private void RegularRPC(int amount, PhotonMessageInfo info)
    	{
    		var sender = info.Sender;
    	}
    

    And no not 2x different do damage.