top down collision check

Get help using Construct 2

Post » Thu Jan 31, 2013 3:06 pm

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.
B
4
Posts: 10
Reputation: 420

Post » Thu Jan 31, 2013 3:11 pm

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.Nimtrix2013-01-31 15:11:30
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jan 31, 2013 3:19 pm

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.GeometriX2013-01-31 15:22:00
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Thu Jan 31, 2013 5:12 pm

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?rikuto1482013-01-31 17:16:36
B
4
Posts: 10
Reputation: 420

Post » Thu Jan 31, 2013 6:38 pm

How about if you use "Is overlapping" instead of "On collision"?
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jan 31, 2013 7:47 pm

So, you're looking for something like this?

Capx here.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Thu Jan 31, 2013 8:06 pm

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.rikuto1482013-01-31 20:14:06
B
4
Posts: 10
Reputation: 420

Post » Thu Jan 31, 2013 8:12 pm

You can strip it down a bit by the way:

offsetOverlap.capx (r117)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jan 31, 2013 8:15 pm

I found the beta 117 thanks. ill try it now.
B
4
Posts: 10
Reputation: 420

Post » Thu Jan 31, 2013 8:20 pm

Not enough coffee this morning, apparently. Nimtrix's is much nicer than mine.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Next

Return to How do I....?

Who is online

Users browsing this forum: Artpunk, OddConfection and 20 guests