playMaker

Author Topic: [solved] Create Object Fine, But Pooler Spawn giving issues  (Read 1186 times)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
[solved] Create Object Fine, But Pooler Spawn giving issues
« on: September 26, 2020, 07:04:05 AM »
Hello !

I have an empty object which always look at enemy.

I wanna create bullets on it.

When I use Create Object action, It working fine as I want.
But, When I pool it, I acting weired.

I couldn't figure out the issue.

I added Add Force - Impulse in Z axis (self) value of 10 on bullet prefab.
See attached video.

Thanks.
« Last Edit: September 30, 2020, 12:00:04 AM by heavygunner »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Fine, But Pooler Spawn giving issues
« Reply #1 on: September 26, 2020, 08:34:02 AM »
Hi.
If you pool you need to Reset things like velocity / rotation / etc.

You can reset some values just before de-spawning and / or on start.

In our game We set the velocity (not force) on the bullet from the weapon fsm, not on the bullet fsm.


heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Create Object Fine, But Pooler Spawn giving issues
« Reply #2 on: September 29, 2020, 02:04:31 AM »
Hello !

I tried. 2 seconds wait, then reset values and finally Pooler Destroy Self.
Still giving weird results.

Any inputs ?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Fine, But Pooler Spawn giving issues
« Reply #3 on: September 29, 2020, 08:24:28 AM »
Hi.
What results are you getting?

is it moving / rotating after respawn?

Also when you spawn. its best to use set position/set rotation actions

So what we do is spawn a bullet, then set position and rotation to the Bullet positioner object (tip of the gun)
Then Set Velocity on the Bullet (you can also do force there)

I also noticed that you are not setting velocity to 0 before despawn.
i can see you set a variable on a move fsm.
Can you show that fsm :)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Create Object Fine, But Pooler Spawn giving issues
« Reply #4 on: September 29, 2020, 11:20:52 AM »
I am getting same result as the video in thread.

I attached move fsm screenshot

What i did on my gun tip is : I created an empty object as gun tip. then, I added action "Look At" and set enemy as target. Player will find closest enemy and save it on a Global variable.

Added Fire fsm on same gun tip. I added that fsm screenshot too

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Create Object Fine, But Pooler Spawn giving issues
« Reply #5 on: September 29, 2020, 05:05:23 PM »
Hi.
From What i can see you spawn on the spawn point.
But the spawned object will not automatically set its rotation.
Before spawn try getting the rotation from the spawn point (world space).
Then after Spawn Set That rotation to the Spawned Object (world space)

if your bullet does not have gravity / drag you also don't need to set velocity every frame and you should set the velocity from the fsm where you spawned the bullet (after setting the rotation)
Or
Don't place the set velocity at start and set a Global Variable on a separate state and do velocity there.
Then on the spawn fsm after set rotation send a event to start the velocity.

You also need to stop the velocity before despawning (Do a set velocity 0,0,0)