Stuck on this....collision and spawning

PestoPesto 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

  • tintrantintran Member Posts: 453

    what's the trouble?
    spawn first, destroy last. so that your actor has a chance to finish his job before he gets destroyed.

  • PestoPesto Member Posts: 38

    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.

  • tintrantintran Member Posts: 453
    edited July 2015

    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

  • PestoPesto Member Posts: 38

    Thanks Tintran!

  • tintrantintran Member Posts: 453

    got it to work yeah?

  • PestoPesto Member Posts: 38

    Still working on it. I'm very new to GS :(

  • PestoPesto Member Posts: 38

    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.

  • tintrantintran Member Posts: 453
    edited July 2015

    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.

  • PestoPesto Member Posts: 38

    tintran - thank you so much for creating those files. They help a lot!!!

Sign In or Register to comment.