med-material / Whack_A_Mole_VR

Whack-A-Mole in VR
MIT License
3 stars 15 forks source link

Randomly Mole Spawner System #223

Closed Xav1204 closed 1 year ago

Xav1204 commented 1 year ago

We needed to add a small animation on the wall to make the experience more immersive. Now, the mole spawn randomly on the wall surface.

The duration of the full wall filling is between 400 and 500 ms.

Updating of the functions name and incoherence in the code.

Xav1204 commented 1 year ago

MoleAnimation

@bastianilso as the previous pull request had a lot of conflicts and unwanted files in the commit, I closed it and I created a new branch because we didn't have a lot of files to change. I added a little change. Indeed, in the previous pull request, I directly disabled diskmole Prefab and it's maybe a problem in the future because if we need to change something on diskmole prefab by enabling it and that we forget to disable again the prefab, the animation won't work. This is why I added an instance of the diskmole and that I disabled it in the awake function like that, we can leave the diskmole prefab enabling. I tried to do this in the start function but it didn't work, between 2 and 5 moles didn't appear. This is why I used the awake function.

Let me know if it looks good for you now.

bastianilso commented 1 year ago

@Xav1204 another approach is to not disable/enable the objects with "SetActive()" directly, but instead set the visibility of the mole by enabling/disabling its Renderer component. This way you are not interfering with any possible scripts, but merely just toggling its visibility. Or even better, we should keep the Renderer enabled but just manipulate the material so the diffuse opacity of the moles is 0 in the beginning. Then in the IEnumerator you can change the opacity to 1.

Xav1204 commented 1 year ago

@bastianilso I've tested your two approaches and by enabling/disabling the renderer component is like enabling/disabling the object. So, we can make one of them, there are no problem with these solutions. However, change the a is more complex because we have two elements that compose the diskmole and one of them has an default material of which I didn't succeed to change is visibility. Moreover, by changing the material made the mole aspect strange so I think that is not a good for us.

Finally, for me, the best solution is to enabling/disabling the object or the renderer of the children.

Please, let me know what you want to do.

bastianilso commented 1 year ago

@Xav1204 let's enable/disable the renderer then, I think that's cleanest and will not mess with any logic in the moles themselves.

Xav1204 commented 1 year ago

MoleAnimation @bastianilso it's also good for this pull request.

Xav1204 commented 1 year ago

@bastianilso I've made the changes that you asked me. Please, tell me if it's that you really expected.