Announcement

Collapse
No announcement yet.

Make instances of a blueprint collide with each other selectively

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Make instances of a blueprint collide with each other selectively

    I have a simple cube falling down and getting stacked up in a grid formation, the cube is in a pawn blueprint and is a staticMeshComponent. It is falling down due to its invisible (non-colliding) parent actor doing an event tick-set location call.

    I want the cube to not collide with other cubes that are falling, and only with those that have already fallen and are static in the grid. What's the best way to do this?

    I've tried a few things now, I was hoping that setting the staticMesh (ie the cube that's falling) to be a WorldDynamic object type and ignore everything apart from the WorldStatic object response, which it should overlap, and switch the cube to WorldStatic when the cube has landed inside the grid, but I've had no luck so far getting that overlap to work. If I just use the overlapAll preset it fires off overlap events like mad. No good.

    I don't really want to do a check after every collision event to do my own sorting - I hope that the collision event will only trigger when it should and no further logic be needed to weed out bad triggers...

    Thanks and thanks!

    #2
    Ok so I tried doing what I need this to do with blueprint code without using collisions and it's causing visible slow down, so here we go again..

    To iterate: I have a moving block that should only collide with static blocks, not with another moving block.

    I have created two new collision object types: BlockMoving and BlockStatic. BlockMoving is what keeps getting spawned, and it is set to only overlap with BlockStatic.

    Once a BlockMoving type has stopped moving I use the following on the blueprint:
    'Set Collision Object Type' to BlockStatic
    'Set Collision Response to Channel' Channel=BlockMoving, New Response = Overlap
    'Set Collision Response to Channel' Channel=BlockStatic, New Response = Ignore

    I still get odd results by doing this, am I attacking this completely wrong?

    Comment


      #3
      Hi RumbleMonk,

      I'm a bit confused as to what you are attempting to accomplish. Do you want the moving blocks to collide with static blocks? If so you need to set your BlockStatic to block, not overlap. The overlap will allow them to pass through. When it becomes a block static set the collision for it to block blockmoving and block blockstatic. When you have it set to ignore they may pass through one another.
      Adam Davis | Marketplace Support | Epic Games
      How to report a bug? | Installation & Setup issues? | Answerhub Bug Reports | Twitter

      Comment


        #4
        Thanks for the reply Adam, and yes - I realized I should maybe have mentioned this.. I'd want to handle what happens when they collide myself, so what I'm aiming with this is essentially capturing the first Overlap call and at the time saying the should all drop. I guess changing it to block could work too, I was worried making the blocks blocked in physics might make them move out of place ever so slightly or something.. they fall down in an exact manner generally, tetris style but smooth, not stepped.

        FYI I tried not having to use collisions this way; each time a block goes into a new grid it checks a pseudo-2d array to see if there's an actor in there, and if it's not it'll keep falling. It basically checks up to 4 player controlled blocks so 4 array checks at a time, but just looking into my array this way causes slight delays visually whenever this happens, making my event tick 'set actor location'-move stutter. I'm hoping collisions will be faster as it's less blueprint oriented.

        Anyhow - wouldn't changing it to block instead of overlap essentially be the same logic though? The oddness I mentioned comes from collision calls happening when they shouldn't, not that I'd expect the blocks to get blocked. My block blueprint instance is set to ignore all but blockStatic by default and when I spawn my new player controlled blocks (not at all close to any staticBlocks) I get onOverlap collision calls.. I doubt I'd have to set the channel responses at instance spawn time if they're the same as default in the blueprint but that's the only logic I can make out of this at the moment.

        Comment


          #5
          Hi RumbleMonk,

          Hm, have you tried using an "attach actor to actor" node and then setting the location to the hit location for when one of the rotating blocks lands on another? Unfortunately this is delving into territory I haven't yet attempted myself but I'm more than happy to bounce ideas if it will be of assistance!
          Adam Davis | Marketplace Support | Epic Games
          How to report a bug? | Installation & Setup issues? | Answerhub Bug Reports | Twitter

          Comment


            #6
            So you mean an additional actor with the sole purpose of being used as a collider? That's an interesting idea.. I kept stabbing at this problem but couldn't get it figured out but this way I could then just delete that actor and the problem of switching collisions off won't be a problem. I'll certainly keep that idea in mind for future projects as I changed the way it works as of far too late (more coffee please) last night;

            I took out the smooth move (set location offset on event tick) and am now doing it stepped, which means I don't have to worry as much about cycles getting eaten up or a slight visual hiccup in the blocks' motion. Now I check a block's coordinates against my pseudo 2d array before each step to check for occupied space or not.

            One thing that would be pretty awesome would be a raycast in place before drawing it - kind of thing. I'm pretty sure I had access to something like that in Torque 2d back in the day. I could essentially place an object anywhere temporarily without drawing it (it'll still be drawn wherever it was), just to see if it would be causing a collision at that place. I'm not 100% sure one can't do that right now but just to throw it out there..

            Thanks for the tip Adam!

            Comment

            Working...
            X