SmartlyDressedGames/Unturned-3.x-Community

NPC Reward volume activates when player is changing stance

Opened this issue · 6 comments

Title, also video showcasing it
Maybe keep this feature but make it so you can toggle it in volume settings in the editor because it might have some uses, also it would be cool to have different rewards given to the player when he leaves volume

volmue

2024-10-27.20-36-13.mp4

From what can I see, the most probable cause is this code in PlayerMovement.applySize:

bool flag = controller.enabled;
controller.enabled = false;
controller.height = num;
controller.center = new Vector3(0f, num * 0.5f, 0f);
controller.enabled = flag;

I suppose disabling and re-enabling collider causes OnTriggerEnter update? I think volume has to keep list of colliders that are currently in it, give reward if it's not yet in the list, and remove from that list in OnTriggerExit.

Unfortunately, yes, I suspect this changed because of the snipped you posted iBowie.

I changed it in the most recent update to fix this issue:
https://forum.smartlydressedgames.com/t/airport-death-bug/25095/2

First, I tested whether the order of changing height and center could fix it:

  1. If height is increasing then move center up first before increasing height.
  2. If height is decreasing then reduce height before moving center down.

Unfortunately, the player would still overlap the trigger. As far as I could tell, disabling then re-enabling the collider was the only way to prevent it from overlapping.

Does this have any particularly bad side effect in your case, biedaktokox?

This change broke most reward list systems that were made before that, most of them are based on reward volume being placed on whole map, and activating it again breaks them. Things like, for example, logic loops, don't work anymore and require stupid workarounds now.
Tales of Terror map has a lot of advanced reward list systems and many reward volumes placed on the whole map. These volumes are activated each time player changes stance, and eats a decent amount of fps, which is another issue.
Most of old systems can be rewritten with that change, but it requires a lot of complex workarounds that make easy things stupid and complex. And there are still things that cannot be rewritten.
iBowie's idea of volume having a list of players in it would be ideal since it would also make onExit function possible, which would allow for much more things done more simply. Personally, I think having reward on exiting volume is must have.

The map, that I'm working on right now, required me to make a couple of rewrites because that change broke them. (Map will be soon on the workshop and it is something you have never seen, just advertising it :))))

I should also mention, that now when player spawns or teleports inside of npc reward volume, he gets reward. If I remember correctly that wasn't the case before.
I don't know if it was intended or is a result of this bug, but regardless it should be kept this way.

That's why I think iBowie's idea is ideal here. We could have reward onEnter and reward onExit and rewards would be given even if player dies, teleports or spawns outside or inside of the volume.

The character controller was disabled and re-enabled after teleports prior to this update, so players would've been triggering the volume after teleports and respawn prior to this update as well.

I'm surprised and curious to hear of reward volumes covering the entire map. What are those used for?

Generally, they are used to give reward lists upon player death or player joining the server. You can narrow that to specific locations that you can only teleport to for example. Later, you do complex stuff with reward lists.