Wildlife

A curated forum for compatible and maintained mods. Users are unable to create new topics in this forum but can reply to existing topics. Please message a moderator to have your mod moved into this forum area.
User avatar
John Doom
Posts: 126
Joined: Wed Dec 01, 2021 5:59 pm
Location: Italy
Contact:

Re: Wildlife

Post by John Doom »

:) Better in CreateBillboard. Try this:
Attachments
wildlife.zip
(5.29 KiB) Downloaded 64 times

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Wildlife

Post by BadLuckBurt »

John Doom wrote: Tue Jan 04, 2022 2:19 pm :) Better in CreateBillboard. Try this:
I tried it but it still isn't working I think. Took some more screenshots. They all end up rotated to the south-east(ish).
This zip-archive didn't have the code or I would've taken a look :)
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
John Doom
Posts: 126
Joined: Wed Dec 01, 2021 5:59 pm
Location: Italy
Contact:

Re: Wildlife

Post by John Doom »

source:
Attachments
Wildlife.zip
(3.21 KiB) Downloaded 70 times

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Wildlife

Post by BadLuckBurt »

John Doom wrote: Tue Jan 04, 2022 2:39 pmsource:
I'm debugging. For some reason the Random.Range call that does the Y-axis degrees is always returning the same number.

- edit

I changed the way the code executes so it spawns 1 animal per frame, the rotation works now.

I have to go walk the dog, after that I'll clean up the code and post the class back here.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Wildlife

Post by BadLuckBurt »

John Doom wrote: Tue Jan 04, 2022 2:39 pmsource:
Just quoting to make sure you get a notification :)

I have attached the changed Wildlife class in the zip file and will explain below what I did, I know you're more than capable of seeing what I did just by looking at the code but others might learn something too or point out errors that I made.

Anyway:

I mentioned the Update() method before but your class did not extend Monobehaviour yet so I changed the declaration to:

Code: Select all

public class Wildlife : MonoBehaviour
This allows Unity to 'be aware' of your class and call built-in methods like Update. I think there's also FixedUpdate and a few other but I haven't used them yet.

I've added a couple of properties to allow Update() to loop through the number of animals it needs to spawn:

Code: Select all

        static bool spawnAnimals = false;
        static int animalCount = 0;
        static DFPosition posPixel;
        static PlayerGPS playerGPS = null;
When the OnMapPixelChanged event fires and the conditions you had in there are satisfied and the current animal count is 0, the map pixel is stored in posPixel and spawnAnimals is set to TRUE.

The Update() method checks if spawnAnimals is TRUE, if it is then it sets a random animalCount if that's currently 0. After that it just calls DoSpawnAnimal.

The DoSpawnAnimal now generates the rotation value and no longer has the for-loop. The rest of your code there is pretty much untouched, the rotation value gets passed to the CreateBillboard method. Once it reached the end, it decreases animalCount by 1. Once animalCount hits 0, spawnAnimals is set to false and the loop stops until the OnMapPixelChanged conditions are satisfied again.

In CreateBillboard, you will noticed that instead of setting the rotation and position values on the model, I do it on the GameObject. At some point it hit me, all those screenshots of the same animals facing the same direction is because there's only one model but many game objects. So when you manipulate the model directly, it translates to all instances of that model. Setting the rotation on the game objects works as expected, they will face different directions.

I think that about covers it, I've noticed some clipping issues when multiple animals spawn, they bunch up pretty easy but that's a matter of tweaking.

I am curious about the way you're creating these game objects. If you look at the method ImportCustomFlatGameobject in MeshReplacement.cs, that does most of what your code does. It's fine if there's a reason why you did it a different way, I'm just curious
Attachments
Wildlife_changed.zip
(2.48 KiB) Downloaded 68 times
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
John Doom
Posts: 126
Joined: Wed Dec 01, 2021 5:59 pm
Location: Italy
Contact:

Re: Wildlife

Post by John Doom »

I don't have time to check, but I trust you. Set a new version number, add yourself too as author, post here source and dfmod and we're ready for nexus :)

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Wildlife

Post by BadLuckBurt »

John Doom wrote: Thu Jan 06, 2022 11:31 pm I don't have time to check, but I trust you. Set a new version number, add yourself too as author, post here source and dfmod and we're ready for nexus :)
Thank you for your confidence in me, thats quite a risk to take ;)

I would like to work a bit on the placement of the animals before we do a new release.

As I mentioned, they tend to bunch up when more than one spawns so might as well improve their placement because people are bound to come back and report it.

I've got some time later today and will post the source + dfmod when Im done
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
John Doom
Posts: 126
Joined: Wed Dec 01, 2021 5:59 pm
Location: Italy
Contact:

Re: Wildlife

Post by John Doom »

BadLuckBurt wrote: Fri Jan 07, 2022 9:26 am I would like to work a bit on the placement of the animals before we do a new release.
At this point it's more important to release it, bugs can be fixed in a later updated. If placement is too problematic, I'd suggest spawning max 1-2 animals per pixel and call it a day for now :)

User avatar
John Doom
Posts: 126
Joined: Wed Dec 01, 2021 5:59 pm
Location: Italy
Contact:

Re: Wildlife

Post by John Doom »

Fixed direction and released on Nexus. You may move to released :)

Post Reply