Post by ghost010 on Jul 5, 2014 8:38:23 GMT
So i'm using the pooling for a couple of things.
Including bullets and enemy's.
I noticed that when an poolobject gets despawned,it saves its position and every thing else.
For enemy's ,this isnt that much of a problem because enemy's will look for the player after spawn.
However for things like bullets, its a big problem.
If the despawned pool object gets respawned, it will spawn with the previous rotation, speed ,movement values.
In other words your bullets will go left,right,up or down instead of straight forward.
This happens with the shooting script in angry bots demo as well with a FSM in playmaker.
With KW_Shot3 and KW_Projectile the bullets dont have the random direction.. but you can only shoot in 1 direction(up) .
Im making a top down shooter so direction is important.
I was able to set rotation, position, speed ect to 0 in a FSM, but the problem with FSM(playmaker) is that when a object with FSM gets despawned, it despawns in say for example state 3.
When you respawn the object from pool, the state is stil on 3 instead of starting from state 1 just like a script :\ .(playmaker forum post on this subject: hutonggames.com/playmakerforum/index.php?topic=7789.0)
I have not found any solution to this and i really dont want to call and destroy objects.
Edit:
After digging some more, the problem seems to be the rigid body, as if the rigid body does not know it has been deactivated and to move your object( being it a bullet,granade,rocket or w/e that needs force)you need to apply force to a rigid body.
So the rigid body still uses the same force on respawn, and because the rigid body gets new force added upon respawn you get old force+ new force= double the force in old direction :S
Setting the rigid body to kinametic solves the problem for objects that dont need the rigid body(like the script from angry bots demo) but setting the rigid body to kinametic is a problem for objects that depend on the rigid body(playmakers add force or any other object that uses gravity like granades).
So this boils down again on that the object needs a reset on despawn(or spawn) and for playmaker we are back at the state problem.(i do not know how to reset an object to begin values in a script).
I really dont know if im missing something or if this is a genuen problem.
Id really hate to resolve this with another pooling program(one should be enough)
www.youtube.com/watch?v=0ip29mVcJfE
Including bullets and enemy's.
I noticed that when an poolobject gets despawned,it saves its position and every thing else.
For enemy's ,this isnt that much of a problem because enemy's will look for the player after spawn.
However for things like bullets, its a big problem.
If the despawned pool object gets respawned, it will spawn with the previous rotation, speed ,movement values.
In other words your bullets will go left,right,up or down instead of straight forward.
This happens with the shooting script in angry bots demo as well with a FSM in playmaker.
With KW_Shot3 and KW_Projectile the bullets dont have the random direction.. but you can only shoot in 1 direction(up) .
Im making a top down shooter so direction is important.
I was able to set rotation, position, speed ect to 0 in a FSM, but the problem with FSM(playmaker) is that when a object with FSM gets despawned, it despawns in say for example state 3.
When you respawn the object from pool, the state is stil on 3 instead of starting from state 1 just like a script :\ .(playmaker forum post on this subject: hutonggames.com/playmakerforum/index.php?topic=7789.0)
I have not found any solution to this and i really dont want to call and destroy objects.
Edit:
After digging some more, the problem seems to be the rigid body, as if the rigid body does not know it has been deactivated and to move your object( being it a bullet,granade,rocket or w/e that needs force)you need to apply force to a rigid body.
So the rigid body still uses the same force on respawn, and because the rigid body gets new force added upon respawn you get old force+ new force= double the force in old direction :S
Setting the rigid body to kinametic solves the problem for objects that dont need the rigid body(like the script from angry bots demo) but setting the rigid body to kinametic is a problem for objects that depend on the rigid body(playmakers add force or any other object that uses gravity like granades).
So this boils down again on that the object needs a reset on despawn(or spawn) and for playmaker we are back at the state problem.(i do not know how to reset an object to begin values in a script).
I really dont know if im missing something or if this is a genuen problem.
Id really hate to resolve this with another pooling program(one should be enough)
www.youtube.com/watch?v=0ip29mVcJfE