top down collision check

0 favourites
  • 11 posts
From the Asset Store
Set of tiles to create a map for top-down games with island theme
  • Hey guys so im trying to get my top down character to change its opacity when against a wall then change back when it leaves the wall. So far I have: Sprite(character) - on collision with Sprite2(Wall) - sprite - set opacity to 50. That all works but how do i turn it off? Would a global variable work? Thanks.

  • You could just do "Sprite is not overlapping wall -> Set opacity to 100", or even "Every Tick -> Set opacity to 100" as long as you place the event above your 50% opacity event.

  • Hmm, yeah there's no inverse action of "on collision", so you could use the closest thing, which is "is overlapping with". This tests if the two are actually overlapping, which isn't possible with a wall which I assume you've set to have a solid behaviour.

    My solution: create a new object, called WallBuffer, which is dynamically spawned and resized to match every wall instance in the map, but is a few pixels wider. Test if the player "is/not overlapping with" this buffer (which is invisible, and isn't set to solid), to change your opacity to 50% and back.

    A quick capx to illustrate my point: here.

    EDIT: Ah, beaten by Nimtrix. That solution is actually more elegant, setting opacity to 100% at every tick, which is obviously then counteracted by the 50% opacity event. Nice.

  • Yeah I tried the not overlapping but since the wall is solid then it technically is never overlapping. Ill try the tick suggestion. Thank you!

    Thank you as well GeometriX i was thinking about that as well.

    EDIT: The tick suggestion causes the character to immediately change back after touching the wall, how should I make sure while the character is along the wall he is "invisible"? Should I go with the buffer suggestion?

  • How about if you use "Is overlapping" instead of "On collision"?

  • So, you're looking for something like this?

    Capx here.

  • That is perfect thank you! exactly what I was looking for.

    EDIT: Problem your file wont open it says I need the 117 version? I'm using it off of steam.

    cant open Nimtrix's either.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can strip it down a bit by the way:

    offsetOverlap.capx (r117)

  • I found the beta 117 thanks. ill try it now.

  • Not enough coffee this morning, apparently. Nimtrix's is much nicer than mine.

  • Alright theubie thank you for the help regardless.

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