How do make a sprite collide with an element in a video?

0 favourites
  • 14 posts
From the Asset Store
Add SubRip (SRT) subtitles to your videos in Construct 3
  • Hi all, i'm trying to make a game that interacts with my webcam feed.

    I have a UserMedia object, with a black and white filter applied to It.

    and i want to make my character to collide with the black parts of the video.

    so he should be able to walk over the white areas of the video feed, and not be able to enter the black ones.

    Any idea how can this be done?

    Many thanks in advance!

  • Wow... something like this could be super epic...

    Poking around at what I can come up with...

  • Cool thanks! looking forward..

    I currently got it working in processing... but its a pain to code the rest of the game engine

  • I couldn't replicate this...

    Thoughts I had that might work (But still not tested)

    Get a plugin made to make the make a object's bounding box change to the color that you pick... (or colors)

    Somehow turn your screen capture into data that can be put into C2...

    If you figure this out... please let me know how you did it

  • ok will let you know if I succeed.

    was thinking maybe storing the frames from the camera as png files (turning the white into an alpha channel).

    then using those PNGs as a Sprite or something of that sort?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • But even if you set it as a sprite... how do you change the collision area?

  • I applied the Multiply filter to it, and now all the whites become transparent alpha channel.

    the question is is there a way in Construct to get the pixel color in a specific X/Y on the stage or the sprite?

  • That's what I was trying to find before... but couldn't find anything like that...

  • I asked about the same thing a couple of days ago. You can do that by using the canvas plugin, by positioning your sprite into the canvas and then using the plugin's "paste object" function. If you want to capture the entire window then resize your canvas to the window's size.

    You then use the expression alphaAt(x,y) to get the alpha value of a pixel.

  • Thanks immortalx, I'll give this a go!

  • Hi guys! I'm bit new to construct and can't figure out how to work with the canvas plugin. I cant find the past function and where to add the expression? could you post bit more detailed explanation? or a sample file?

    many thanks!

  • Drag the sprite to the top left where the canvas frame is. Right click to paste. Then drag again the sprite to move it out of the way.

    Now if you place the mouse cursor over the canvas, the rgba values will be displayed. If you want just the alpha value replace "rgbaAt" with "alphaAt"

    https://dl.dropboxusercontent.com/u/14855413/c2/canvas.capx

  • Brilliant! this works great! many thanks!

  • The only thing is when I paste the UserMedia object into the canvas it drops all the effects applied, and pastes the source video as is. which is not a big deal for my current project but still would be nice if the effects could be also transferred to the canvas object.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)