Make something go through one side

Hello, how can I make it so that my player can go through a block on the left side but can't pass through the right side?

JeffreyDriver

  • Posts: 2017
This is what I used recently. See attached image.

The animations 'Closed' and 'Open' not only differ visually, but the closed one has a collision shape, while the open one doesn't.

You change the values in the 'if' statement to your own needs. You can also change the 'less than' to greater than to change the direction that you want to block.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

Thanks but I tried it and it didn't work, it only works sometimes, and other times it just lets me go through it. This is what I did, tell me if you see something wrong:

Never mind I changed it to what you did but now it doesn't let me pass through either side...

JeffreyDriver

  • Posts: 2017
It works for me. Have you tweaked the value 11?

What happens with yours? You could try switching the collision shape to and from a sensor.

Another method would be to have two collision shapes, next to one another. The one on the left to detect if the player has approached the door from the correct direction.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

I'll try playing with the number 11 but I'm not sure if it will change much. Here's what I did:

I think I found the problem! I accidentally did X-On screen for the first one instead of X-Center! I hope this is the solution!

It fixed it a bit but it still doesn't always work.... I'll try playing with 11...

JeffreyDriver

  • Posts: 2017
What are the dimensions of your collision shapes for your player actor?

« Last Edit: March 06, 2018, 03:56:47 pm by JeffreyDriver »
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

I realized what the problem is and I don't know if there's a solution... I'm trying to make it so that enemies only go through one side to and if I'm on the right side they'll be able to pass

CmdrWhitey13

  • Posts: 502
I realized what the problem is and I don't know if there's a solution... I'm trying to make it so that enemies only go through one side to and if I'm on the right side they'll be able to pass

Collision Sides
One point to watch out for is that collision sides are based on the rectangular, bounding box of the shape that collided, so if you used a circle or a polygon, pay attention to the results.



http://www.stencyl.com/help/view/collisions-and-groups/

JeffreyDriver

  • Posts: 2017
I realized what the problem is and I don't know if there's a solution... I'm trying to make it so that enemies only go through one side to and if I'm on the right side they'll be able to pass

The techniques shown above, combined with collision groups will help you
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

ETHproductions

  • *
  • Posts: 429
If 11 represents half the width of your actor, Jeffrey, I think you could replace <x-center of actor - 11> with <x of actor>. Or is it just a value you had to mess around with to get the right feel?
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

JeffreyDriver

  • Posts: 2017
Yeah, it's not the half width. It's just a value I tweaked to get it to work.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

I made a very simple solution guys, it doesn't involve all the things you guys are telling me to do, I'm just going to use this (but thanks anyway :), I hope it works!: