Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: jellyam on August 26, 2014, 02:35:42 PM

Title: 2d bullets, how do i get cloned objects to destroy themsleves on impact?[SOLVED]
Post by: jellyam on August 26, 2014, 02:35:42 PM
I'm making a little side scrolling game with an enemy that shoots a bullet object at the player every couple of seconds, however i want the bullet clones to be removed once they hit anything in the scene. I did create an fsm that has a trigger 2d event that sends a destroy self action on the bullet prefab but it doesn't seem to be working. maybe its something with wrong with my spawner fsm which i've got on my enemy guy. I hope this made sense

i've attached a couple of pictures for reference

Title: Re: 2d bullets, how do i get cloned objects to destroy themsleves on impact?
Post by: bizilux on August 26, 2014, 02:56:55 PM
first of.... go into play, and when you see bullet spawning, hit pause. then click on that bullet, hit resume and check its movement FSM.

and pay attention if it will go from movement state into self destruct state.
im suspecting it wont, so here is ur problem, with colliders.
report back with ur problem, and how colliders are set up on bullets, and rigidbodies and on enemy too

most of times, its problems with colliders, they need rigidbody 2d on it most of times, or collision detection settings changed
Title: Re: 2d bullets, how do i get cloned objects to destroy themsleves on impact?
Post by: Lane on August 26, 2014, 03:03:07 PM
Probably spawning in a spot where the bullet collider is overlapping the enemy collider, so it instantly registers a collision.
Title: Re: 2d bullets, how do i get cloned objects to destroy themsleves on impact?
Post by: jellyam on August 26, 2014, 03:44:21 PM
after taking a closer look it was two things causing my problems, my bullets didn't have a rigid body attached to them and my enemy had a collider on him that would cause the bullets to disappear on impact when i would go to put a rigid body on the bullets. I changed those two things and bam, its working. This is good enough for me for right now but how would i shoot a slow moving bullet from under the player and have it not respond to gravity (which the rigid body inherently puts on objects)

and thanks for the quick response too   :)
Title: Re: 2d bullets, how do i get cloned objects to destroy themsleves on impact?[SOLVED]
Post by: bizilux on August 26, 2014, 05:03:19 PM
rigidbody 2d settings on component.

either put gravity scale to 0, or tick is kinematic, and read more about it on unity docs