ShootingBattleVRC

ShootingBattleVRC by K1911jp

[World Image]


In this world, you can do shooting battle.
Collision detection and damage management are finely controlled by UDON.
So, you will fell none stress. Please try it !

[World Link]

  • I will publish to Community Labs at December 18, 2020 Japan time 0:00

There are several game modes and weapons. Please see videos :slight_smile:
[GameMode]


[Weapon]

Other

Thank you!

2 Likes

And, this is core code of damage gimic.
There are 3 parts.

  • Weapon - Pistol have this. When pull the trigger, send network messeage of fire.And, Owner check if it hits PlayerInformationUI using raycast. If it hits PlayerInformationUI, it will notify the damage.
  • PlayerInformationUI - This is collider of player. Following every player registerd.
  • PlayerBelt - This is counter of HP. There is only one object locally.

[K1_Weapon]


    public override void OnPickupUseDown() {
        /* Fire Messeage*/
        SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldFire));
    }

    public void WorldFire() {
        
        /* Hit check using Raycast */
        if (Physics.Raycast(new Ray(muzzleTran.position, muzzleTran.forward), out hit, rayDistance, layerMask)) {
            tmpPlayerInformationUI = hit.transform.gameObject.GetComponentInParent();
            
            /* Send damage to PlayerInformationUI (when Owner) */
            if (tmpPlayerInformationUI != null && Networking.IsOwner(Networking.LocalPlayer, gameObject)) {
                tmpPlayerInformationUI.OnDamage(damageVal);
            }
        }
        /* Sound,Animation */
        audioSource.PlayOneShot(fireSound);
        MainAnimator.SetTrigger("Fire");
    }

[K1_PlayerInformationUI]


    public void OnDamage(float damageVal) {
        if (damageVal >= 100) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage100));
        } else if (damageVal >= 90) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage90));
        } else if (damageVal >= 80) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage80));
        } else if (damageVal >= 70) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage70));
        } else if (damageVal >= 60) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage60));
        } else if (damageVal >= 50) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage50));
        } else if (damageVal >= 40) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage40));
        } else if (damageVal >= 30) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage30));
        } else if (damageVal >= 20) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage20));
        } else if (damageVal >= 10) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage10));
        } else if (damageVal >= 0) {
            SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, nameof(WorldDamage0));
        }
    }
        public void WorldDamage0() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(0.0F); }
    public void WorldDamage10() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(10.0F); }
    public void WorldDamage20() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(20.0F); }
    public void WorldDamage30() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(30.0F); }
    public void WorldDamage40() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(40.0F); }
    public void WorldDamage50() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(50.0F); }
    public void WorldDamage60() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(60.0F); }
    public void WorldDamage70() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(70.0F); }
    public void WorldDamage80() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(80.0F); }
    public void WorldDamage90() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(90.0F); }
    public void WorldDamage100() {MakeVFX(); if (playerInformation.PlayerId == Networking.LocalPlayer.playerId) playerInformation.PlayerBelt.OnDamage(100.0F); }

[K1_PlayerBelt]
    public void OnDamage(float damageVal) {
        PlayerHp -= damageVal;
        if (PlayerHp <= 0) { PlayerDead(); }
    }
2 Likes

Me and my friend came across this world the other day. We spent the better part of an hour in there. It was pretty fun!!

1 Like