sPOiDar / fvtt-module-stream-view

FoundryVTT module that provides a minimal UI view with automated camera work, ideal for streaming or recording games.
MIT License
11 stars 11 forks source link

Current combatant token is not always found #5

Closed Dan5033 closed 3 years ago

Dan5033 commented 3 years ago

As stated, I suggest that when in combat, the Camera will try to fit the player and any targeted token on the screen. That way, the audience can see the battlefield more clearly as well as usage of mods like Automatic Animation will allow audience to see arrows fly across the screen!

p/s: first time using github. So if someone can label this as enhancement, that'll be great!

sPOiDar commented 3 years ago

This is indeed already a feature, you will need to ensure you have Camera Mode set to Automatic, and don't have Directed Combat enabled. If this is how you have it configured then during combat the camera will focus the current combatant, and any tokens they have targeted.

If your settings are all correct and it's not working, can you look at the console (hit F12 and select console), and check if there are any errors? Also, confirming that this behaviour exists without other modules involved would help.

Dan5033 commented 3 years ago

Camera Mode is set to Automatic Directed Combat is unchecked

Here are the error message I can see in the console image

Setup. Modules activated are only Stream View and its dependencies. I have 2 tokens on a scene. One used as the playerand the second is the target. On the player's turn, targetting or un-targetting the target does not change the camera at all. Moving the target makes the camera jump to the target then back to the player

sPOiDar commented 3 years ago

Hrm, for some reason it can't find the token for the current combatant on the canvas... can you type the following into the console and post the output for me?

game.combat.combatant.token.id
game.canvas.tokens.getDocuments()
Dan5033 commented 3 years ago

I could not replicate the issue that causes the error message to appear. So I recorded a screen recording of what is currently happening regarding the targeting issue. You can watch it here: Test footage for stream viewer

sPOiDar commented 3 years ago

The error was very confusing to me, and combat tracking won't work if that occurs - I will add some handling for that case, but I'm not sure how it could occur, only thing I can think of is if combat was happening on another scene from the one that the stream view has active.

As to the video - because of the way targeting works in Foundry (targets are per-user, not per-token), there are some conditions for the target focusing to work:

So, if the combatant in your test is player-owned, but you're doing the targeting from a GM user, that would explain why it doesn't update the focus. If you login as the owner instead and select the token on the player window, it should work as expected. So for normal gameplay scenarios (players controlling/targeting for their tokens, GMs controlling/targeting for NPCs), I think you'll find this feature does the right thing.

Let me know if that makes sense.

sPOiDar commented 3 years ago

I've pushed the fix for the error condition you encountered, however I'll leave this issue open until I hear confirmation that the targeting works as expected when logged in with the expected users.

sPOiDar commented 3 years ago

I'm going to close this out, since I've not heard back. If you still have an issue, please feel free to respond.