Stuck on this....collision and spawning
Pesto
Member Posts: 38
I am trying to make a simple scene where I have one actor moving to the left on the screen. It collides with another actor and gets destroyed but at the same time it spawns a new actor that falls away (like it died).
I am having trouble with the spawning and dying after the collision. Any help would be appreciated
Comments
what's the trouble?
spawn first, destroy last. so that your actor has a chance to finish his job before he gets destroyed.
I can't seem to have the spawned actor bounce off the actor (wall) it collided with.
I'm trying this out with simple block shapes (actors) right now but what I want to ultimately do is have my animated sprite of my flying character across the screen. When he hits the wall, I would want to change to another sprite animation of him bouncing off and falling...and then bouncing off ground a few times.
you can just use the same actor but when you collide and falls, you can change his image or choose to animate. that way he'll keep the bounced effect and you don't have worry about spawning another actor to take on bounced values.
Like when you hit the wall you can set some boolean to true and then based on the boolean you can accelerate toward the ground and animate
Thanks Tintran!
got it to work yeah?
Still working on it. I'm very new to GS
Not sure how to make actor fall after he collides. Also when he collides he keeps trying to "push" the obstacle. I wish there was a simple "bounce" behavior. Just struggling on creating it.
something like this maybe?
bird has intial linearVelocityX set to some negative number to fly left.
then it collides with wall
when actor overlaps or collides with wall
set attribute dead to true
when attribute dead is true
accelerate downward (270 degrees).
and collide will take care of the bouncing for you.
You can play with the bounciness value of bird in physics attributes.
If it keeps pushing the wall is probably because you're using "move" instead of setting an initial linearVelocityX value..Move act on every frame and keeps trying to move even if it bounces and after it bounces it still tries to move, where if you set Initial linearVelocityX value, that's only set once and if the collision causes a bounce the linearVelocityX will change accordingly so you don't end up pushing the wall repeatedly.
tintran - thank you so much for creating those files. They help a lot!!!