suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
49 stars 11 forks source link

[Bug?]Pooling System Particle #2419

Closed moepi2k closed 4 months ago

moepi2k commented 5 months ago

i faced in to a weird issue when using pooling system with projectiles. i setting up my projectile so i dont need to instantiate the effects like so: https://gyazo.com/34745ab12648180b93c52733ee604253

my projectile and my impact effect is a child of it and should enabled/disabled in setup when projectile launched.

this is my projectile in editor https://gyazo.com/3b2f4c7d9be79e7ff8b9484ee6b8d39a as you can see i use play on awake on all particles

the problem now, when the games starts id disable all play on awake even on the audiosourcesetter like: https://gyazo.com/2c529b1ef193d6061a2c69ff415b98c0

so with this problem, the particle system is not running properly. i checked the code and cant find anything related which could disable the particle 'play on awake'

so do you have an idea what cause it?

moepi2k commented 5 months ago

ok i tested, same happen with missiledamageentity, but the diffrence is even when playonawake is disable in missile, the effect is working. but in projectiledamageentity after pooling is rotated once and start again from first projectile, you no longer have any particle effect becuase play on awake is disabled. really weird. another problem when use angle the hit pos of the impact effect is wrong https://gyazo.com/d0451d5c45093e8d4dbffcc856a6f237

as u can see in editor the raycast goes in streight and seems blocking by the fence and the impact effect colliding there even when the projectile goes over the fence

insthync commented 5 months ago

Can you help me to fix it?, I gave you an access to the repo for that purpose, I hope you will anytime soon, whats I can see are only changing function/class to be virtual. It is actually not help to fix bugs and not improve its performance.

darkkriteus commented 5 months ago

magmaBall_Impact will only activate Play On Awake when it is activated, otherwise it will be unchecked also remembering that its child effect does not have the Game Effect component

insthync commented 5 months ago

@moepi2k HINT: look at FxCollection.cs, learn about particle system's play on awake behaviour by create 2 particles in empty scene, one for parent another as its child, then try set play on awake setting

moepi2k commented 5 months ago

magmaBall_Impact will only activate Play On Awake when it is activated, otherwise it will be unchecked also remembering that its child effect does not have the Game Effect component

since the projectiledamageentity is already a pooled object it makes no sense to add gameeffect to child objects since it only need to enable disable onspecific states. but anyway i tested with adding gameeffect to child, and with it the projectile completly not working.

and when u look at the projectileentity code thats how it should work. playonawake when gameobject gets activated. so actually i dont know how this should work, since there is no example.

thats the part where it just should enable the child object https://gyazo.com/0a8059aad161882cc45d536db27d5e3c

thats how it worked always when this projectile was made

moepi2k commented 5 months ago

@moepi2k HINT: look at FxCollection.cs, learn about particle system's play on awake behaviour by create 2 particles in empty scene, one for parent another as its child, then try set play on awake setting

thats what i did. when i put an particle as child in an disabled object with playonawake. it automaticly plays when the object gets activate. but it does not with projectiledamageentity

insthync commented 5 months ago

What you did? learn about particle system, then did you know how it work like if: parent particle's play on awake is on, then its children will on or not if it was off? and parent particle's play on awake is on or not, if its children is on later?

insthync commented 5 months ago

Did you ever find how FxCollection.cs is being used?, and how is it working?

moepi2k commented 5 months ago

i know how particles works. maybe u interpreted my video wrong. i showed u that playonawake is enabled on parent object. i know that childern automatly are enabled also then. the thing is in fxcollection it disable all playonawake in the InitPrefab method. so when its disabled how should it play? when i disable that part in fxcolleciton. everything works fine.

if there is any step i miss i would be greatful if u can explainsince there is zero docu or example of it.

the ProjectileDamageEntity is already a pooled object so i assume the rest of its childer object is handled in the projectiledmaageentity script itself like enable impact effect etc.

and by the way. i just tryied old projectiledamageentity script where the predicten step was in. and the pos of impact effect is fine again.

here with the latest projectile script https://gyazo.com/a04508d34dfa47d7321883c90c69b7c2

and here with predicten step, (3 commits behind latest one) -> https://github.com/suriyun-mmorpg/UnityMultiplayerARPG_Core/blob/bea180e34e06a464e62ddcc92a8f2e30a77f6b18/Scripts/Gameplay/DamageEntities/ProjectileDamageEntity.cs

https://gyazo.com/9012f1a2536b120b454901a9e211b90e

insthync commented 5 months ago

Did you see FxCollection in BaseDamageEntity?

moepi2k commented 5 months ago

Did you see FxCollection in BaseDamageEntity?

yes i seen it

insthync commented 5 months ago

Did you see its (FxCollection) constructor?

moepi2k commented 5 months ago

yes i also followed the whole path https://gyazo.com/c86bde3cd8305195dc5896cd2826aabb playFx is calling which should play all particles in child and i know normal behaviour from particle when u play particle by code u can just use xxx.Play(); even when playonawake is disable and it plays. but here it does not.

only when i disable playonawke like https://gyazo.com/d1a701a6e1bc9c0d74db55f07fbf3e5f

its working. soo im really have no clue why, maybe i oversee something. but just from the logic of projectiledamageentity script it should be easy like that to just add effect as child an assign properly

insthync commented 5 months ago

All particles playOnAwake will be set to false, if the projectile damage entity is instantiated by pool system, if your impact effect is child of projectile damage entity, then it will be false, and it won't play by just activate the impact effect because playOnAwake is false and Play function which is part of FxCollection won't being called so it has nothing will be played, that is the problem, it is easy to fix, I think I tell you enough, hope you can fix it.

moepi2k commented 5 months ago

yea one solution will be to change impacteffect playonawake in projectiledamageentity, other wouldbe to just remove that part from fxcollection to disableonawake, since i dont see the benefit of it? it will confuse ppl more then it helps?

but yea so the projectile how it is now is bugged and thats what i wanted to know. it was not a fautl on my side

insthync commented 5 months ago

Yes it is not your fault, but I want you to help me fix it, I gave you an access to the core repo for years, I expect that you really can help me.

insthync commented 5 months ago

About fx collection, it is being used by damage entity, that is why it is there, damage entity can be pooled and its effects should be manageable that is its benefit.

moepi2k commented 5 months ago

ok i will fix the projectiledamageentity and send you my changes so u can check