Toly65 / UdonCombatSystem

A simple combat system designed for VRchat
MIT License
26 stars 2 forks source link

respawn #10

Closed Cart00nHead closed 2 years ago

Cart00nHead commented 2 years ago

Hey sorry to bother you again

so I'm having an issue where the first time you die everything works fine but after that you skip going to the death box and go straight to respawn but your body gets stuck behind any terrain/buildings between you and the respawn. you then can only move in one direction towards where your body had been stuck

any help / advice would be greatly appreciated :) cheers CH

Toly65 commented 2 years ago

the issue is that are 3 different issues stacking on top of each other.

  1. VRchat's networking is slow and thus the system puts players in a little box to allow all the damage to be applied
  2. for some mystical reason, it doesn't do number 1
  3. your issue, probably because of number 2 causing multiple teleports to happen within the same frame

I'm working on the system right now as it's had a fit for the millionth time now, but no matter how much I try to unravel those 3 issues in a trench coat, being one big issue it doesn't wanna play nice, the simplest solution would be to remove the death box system entirely, but that requires having some other way of making sure players don't spawn with less than max health

This can be done externally by you if the players are spawning in something like a lobby, with their health being hidden till the start of the next match, and their health is maxed out at that point instead of directly at respawn,

The health manager has an option to straight-up disable the respawn box if deemed necessary, but of course, it's recommended to do the above if you decide to do that.

Cart00nHead commented 2 years ago

Thanks for getting back to me

I understand, that's definitely frustrating I feel your pain. I wish i could help out but you are far more talented than me 😅 I only just started learning coding myself

Cart00nHead commented 2 years ago

It seems disabling the respawn box didn't help with my issue of getting trapped behind stuff.

after doing a little research it appears its a common bug with localPLayer.TeleportTo the solution was to add a sendcustomeventdelayed to give it time to catch up

SendCustomEventDelayedSeconds("RespawnObject", 0.1f);

Cart00nHead commented 2 years ago

that made it work fine, however it still suffered from the issue you mentioned taking delayed damage causing you to not have full hp on respawn so adding a second delay before you heal seems to have fixed that issue as well ( 99% sure anyway) i have only tested it locally

Debug.Log("respawn Triggerd");
    localPLayer.TeleportTo(RespawnPoint.position, RespawnPoint.rotation);
    CurrentHunger = 100.0f;
    SendCustomEventDelayedSeconds("RespawnHealth", 0.1f);
    CurrentHealth = RespawnHealth;
    //localPLayer.CombatSetCurrentHitpoints(RespawnHealth);
    Dead = false;