Bar breaking into halves, then quarters ...

tintrantintran Member Posts: 453
edited July 2015 in Miscellaneous

I wanted to create a bar that falls
to the ground/land
and when it collides with land, i want to destroy it and create two actors (2 halves) in its place.
And when each half collides with land again, it should break into 2 halves again. This process might repeat until the pieces reach a certain minimum width/height threshold.

But there's no way to do this without making these pieces as separate actors width defined size ahead of time, is there?
Like is there away to reuse the same initial bar actor and just change the width/height based on my current actor's width/height (the actor that i am about to destroy)?
I thought about using game attributes but it'll run into concurrent issue where let's say my piece is one half and it's about to break into quarters, but if i already got a quarter that's colliding with land at the same time it'll want to break into eighths so i can't really use game attributes in this case as i don't know which piece i am currently breaking in order to set the width/height.

So is there away without making these predetermine sizes of actors ahead of time?

Also another question is "Is there a way to get a collidee's data?" like if i have 2 objects that collided and i wanted to trade info between the two like for example if object 1 collided with object 2 i wanted to object 1 to change size (or some other attribute) to object 2's size (or something other attribute) is there a way to do it directly without using game attributes... as when there are many things happening at the same time game attributes will mess things up.

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited July 2015

    Purely theoretical suggestion here (totally untested, and not really given much thought).

    Could you not do something like this:

    When actor collides with floor, spawn two of the same actor (half the original size), destroy the original, and shoot the two up at a random direction with a reduced force (maybe based on the size of the object). Have the same code on the one actor that basically spawns two of itself every time it bounces.

    Like I say I haven't tested this in anyway so could be a bit of a long shot.

    Edit: you'd have to find a way to stop splitting it at some point, maybe based on the velocity speed after the bounce??? If it's really low (hardly bouncing) stop the continuous spawn.

  • tintrantintran Member Posts: 453

    @KevinCross said:
    Purely theoretical suggestion here (totally untested, and not really given much thought).

    Could you not do something like this:

    When actor collides with floor, spawn two of the same actor (half the original size), destroy the original, and shoot the two up at a random direction with a reduced force (maybe based on the size of the object). Have the same code on the one actor that basically spawns two of itself every time it bounces.

    Like I say I haven't tested this in anyway so could be a bit of a long shot.

    Edit: you'd have to find a way to stop splitting it at some point, maybe based on the velocity speed after the bounce??? If it's really low (hardly bouncing) stop the continuous spawn.

    That's the thing though how do you determine the size without using game attributes?
    Like if i want half the size? how do i know where to get this information from. Because when you spawn an actor there's no way to tell it to make half the size of the actor that you're about destroy without using game attributes...if i use game attributes things might get buggy when many of these pieces are happening at the same time.

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    @tintran said:
    how do i know where to get this information from. Because when you spawn an actor there's no way to tell it to make half the size of the actor that you're about destroy without using game attributes

    Oh yeah, forgot about that. Like I said I didn't give it much thought >.<

  • SocksSocks London, UK.Member Posts: 12,822

    @tintran said:
    That's the thing though how do you determine the size without using game attributes?

    You can smuggle information through unused attributes, for example you could use the Spawner's rotation setting to determine size. Set the Spawner's rotation to half its own length value, then in the spawned actor change the actor's length to the current rotation - then set the rotation to what it needs to be.

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Socks, using the rotation is dicey as it gets normalised to the 360 deg range once passed.

    I prefer using the x and y positions, sending values as decimal values.

    Project example incoming.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited July 2015

    @tintran

    Here a sample project. (Attached)

    Tweaking of the collision rules will give the desired effects.

    e.g. impact velocity, what it needs to collide with to break, or minimum bar size.

  • ArmellineArmelline Member, PRO Posts: 5,354

    I'd probably just use a game attribute.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited July 2015

    @Armelline said:
    I'd probably just use a game attribute.

    I agree, works just as well in this case and is simpler.

    @tintran said:
    ... how do you determine the size without using game attributes?

    This is the reason for the example.

    Also, in some situations it is quite handy passing info like this.

  • tintrantintran Member Posts: 453

    I tried to pass information through using decimals of rotation..but the result didn't look as cool as i had imagined . I imagined it to look like realistic breaking but it ended up looking like blocks that just split and the movement isn't realistic..well it was worth a shot.

    There is a rule at the bottom that turned off, turning that rule on is even weirder looking hehehe.

  • tintrantintran Member Posts: 453

    @Hopscotch said:
    tintran

    Here a sample project. (Attached)

    Tweaking of the collision rules will give the desired effects.

    e.g. impact velocity, what it needs to collide with to break, or minimum bar size.

    Yours look much more convincing than mine.

Sign In or Register to comment.