playMaker

Author Topic: Object not destroyed after collision detection event  (Read 2648 times)

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
    • View Profile
Object not destroyed after collision detection event
« on: February 02, 2016, 01:23:59 AM »
Hello,

I have been trying to follow the tutorial from here.

I got the basics working with the movement and ball being launched.

The main problem however is in the collision between the ball and the bricks. I added Rigidbody2D on both the bricks and the ball, I also have a box collider on the bricks and a circle collider on the ball.

I have an FSM with a "Get Collision 2D Info" and it saves the object in a variable. Then a Send Event to another state (same FSM). The second state has a "Destroy Object" action that uses the variable mentioned earlier. Yet, when I hit play and the ball collides with the bricks nothing happens. It acts as if the collision didn't happen in the first place.

Thank you very much in advance.





jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15082
  • Official Playmaker Support
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #1 on: February 02, 2016, 01:46:43 AM »
hi,

 what technic are you using inside PlayMaker to detect collision?

Bye,

 Jean

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #2 on: February 02, 2016, 01:53:01 AM »
I tried first the "Collision 2D Event" and send an event to the state that has the "Get Info" action but it didn't work. Then I saw a thread here where Alex mentioned that "Get Info" would do it (in a scenario where a bullet hits an asteroid) alone and I downloaded the sample file that was included.

So I removed "Collision 2D Event" and the setup is as I mentioned in the original post... just the "Get Info" and from there to "Destroy object".

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #3 on: February 02, 2016, 09:08:09 PM »
Bump, couldn't figure out a solution to this. Any help would be greatly appreciated.

Zeldag

  • Full Member
  • ***
  • Posts: 198
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #4 on: February 03, 2016, 01:42:03 AM »
Not sure, just a noob trying to be helpful.

But couldnt you simply add an fsm on the bricks:
State1: Add action; Collision event 2d. Set the collision tag to be the 'ball' (and tag your ball object with that tag). On collision send event to State2.

State2:  destroy self (and any point adding you need to do before that or whatever).

Im not sure if this messes with your tutorial progress, but may work for the game in general... Good luck.

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #5 on: February 03, 2016, 01:50:10 AM »
Well that is actually VERY strange. It worked as you mentioned exactly, problem is, I had the same exact setup on the ball with the tag being "Bricks" and it would destroy the object in question.
However, that didn't work, it worked when the brick had the code. If someone can explain the difference it would help greatly.

That said, there is a new problem, for some reason the ball bounces of some of the bricks and some no. Not sure why, I am using the same prefab.

I did the setup with a wait "0.5" before the destruction of the brick so the ball could bounce.

Thank you very much Zeldag! :)
« Last Edit: February 03, 2016, 02:19:47 AM by Vallar »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15082
  • Official Playmaker Support
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #6 on: February 03, 2016, 11:59:38 PM »
Hi,
 
I'll mark this thread solved, please create a new thread for your missing collisions if it still occurs ( you'll find that you need to increase the solver iteration count if your ball goes fast, and increase the depth of your collider, if the ball between two refresh goes to fast it may simply have passed the collider).

 Bye,

 Jean

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #7 on: February 04, 2016, 12:02:03 AM »
Thanks a lot Jean.

Do you have any insights though why the FSM would work on the brick but won't work on the ball?

Either way, I'll test a few things again before I post another thread about the collision.

Thank you very much!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15082
  • Official Playmaker Support
    • View Profile
Re: Object not destroyed after collision detection event
« Reply #8 on: April 14, 2016, 10:48:19 PM »
Hi,

 Yeah, reference that new post here as well, for people to bounce and learn from our struggles :)

Bye,

 Jean