Started by
Puglord123
on
Topic category: Help with Minecraft modding (Java Edition)
Hello, I recently made and released a FNaF mod that has animatronics which switch between a Night Time mode and a Day Time mode. I realised that this switch between the modes happens only if the entity is in the FOV of a player. Would there be any way to fix this and make it so that it happens regardles of if the player is looking at the entity, or is this hard-coded?
Edited by Puglord123 on Thu, 01/04/2024 - 15:54
I'm not sure why FOV would be affecting entities- I've been able to run code before as long as entities are nearby, if not directly in the player's field of view. Is it possible your entities have too low of a rendering distance? I usually set it to at least 32 meters for anything with ranged or special abilities. They could also be set to despawn when idle, though they'd have to be much further away for this to be the issue.
Mindthemoods, I also don’t understand why this works like it does, but somehow it does, and how do you check your entity rendering distance and how do you change it?
Also, they are not set to respawn when idle, that is for sure, so that can’t be causing it
In the 'behavior' tab of an entity, there should be a box for follow range, and tracking range. You can increase tracking range to allow essentially increase or decrease an entity's simulation distance. However, if the entities are still moving and otherwise behaving normally when outside the player's view, there might be something else that's preventing your procedure from working. Could you send a picture of the procedure you're using to switch the entities?
Here is the procedure i'm using
https://imgur.com/a/GuWjqjb
What's weird is that the night time modes do move if they are out of a players FOV, but they don't switch modes. And the follow range of every animatronic is 512.
Maybe it's also because of the fact that I made a FNaF 1 map recreation that i test everything on and i just sit in the office, and that's when they don't want to switch.
Also, I recently got a tester for this mod and he says that they switch if you are not looking at them, so maybe it's just the thing with the office
Huh. That is weird, I would expect something like that to work. It might have something to do with mob spawning behavior: if the animatronics are classified as mobs, minecraft has some weird rules about not spawning them within certain ranges of the player, but I wouldn't expect that to effect things spawned in manually. I would guess it's still not necessarily the spawning procedure, but something else about the mobs- maybe since the new mobs won't have their attack target set to the player, you need to manually reset it to get them moving? I would recommend testing it on your version of minecraft, not just the test client, there are some rare issues that seem to resolve themselves when tested externally. But yes, I assume it probably has something to do with the mob's AI, not the switching procedure, which looks fine.
I tested on my version of minecraft, and it seems to work! Thank you so much for your help!