How do I make the player colliding with walls

Get help using Construct 2

Post » Fri Aug 22, 2014 9:43 am

i use :
every tick -> set playerposition to mouse X & Y
i have 4 walls . when i move the mouse over the (solid! ) walls the player goes through them like butter.

how to prevent this ?
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Fri Aug 22, 2014 10:00 am

what would you want to happen when the mouse is over the wall?

would using drag and drop and automatically dropping if mouse is over wall be a solution?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 22, 2014 10:02 am

no the player sprite should just NOT go through a wall even if the player sprite position is under the cursor
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Fri Aug 22, 2014 10:09 am

Sure, what should the sprite do when the cursor is on the other side of the wall?

I assume adding the condition mouse cursor is not over wall is not enough..
Last edited by LittleStain on Fri Aug 22, 2014 10:11 am, edited 1 time in total.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 22, 2014 10:09 am

Have you a HTML5 demo or a demo capx file? Normally it should be enough to set the walls solid and add the platform behavior to the player.
Image Image iTunes: Match3 | Google Play: Match3
B
100
S
35
G
30
Posts: 1,136
Reputation: 28,085

Post » Fri Aug 22, 2014 10:17 am

It would be a lot easier to answer your question if it would be clearer what you are trying to achieve..
if you want to restrict the player to a certain area, using clamp would probably help..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 22, 2014 10:21 am

Okay im uploading a windows32bit build now.
in the meantime i will try to describe what i want to do.

You have a room where enemies are bouncing around against walls.
your player is UNDER your cursor and you have to avoid the enemies.

BUT you can cheat if you just place your cursor with the player in a corner so deep that the enemies wont hit you.
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Fri Aug 22, 2014 10:24 am

B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Fri Aug 22, 2014 10:32 am

using clamp would work

player set x to clamp(10,400,mouse.x)
player set y to clamp(10,800,mouse.y)

I had to guess the numbers, but the 10 should be the width of the walls, the 400 should be the projectwidth-the width of the walls
800 = projectheight-width of the wall..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 22, 2014 10:33 am

wont this be a problem on a mobile device wehn the fullscreen is scaled with letterbox scale or so?
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 44 guests