How to make a ball reposition inside an invisible barrier on a different layer?

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

Make a ball in a different layer to a solid wall that’s hidden move to a fixed position when the ball is clicked inside that invisible solid wall. (Not outside of it or on the edge of it. Only on the inside)

What is the expected result

What should happen is that the ball returns to a fixed position if the ball’s left mouse button is clicked whilst inside an invisible ‘barrier’ that’s situated in a different layer.

What is the actual result

It’s hard to explain what the actual result is so screenshots are attached below to better explain it.

Related screenshots

Project files (optional)

I don’t think this is needed but please let me know if it is.

In your second event “Behaviour Physics2 of Barrier is activated” cannot be true because the event above it deactivates the Physics2 behaviour.
Try removing that condition.

1 Like

Hey there,

I removed it but now whenever the mouse is clicked the ball will go to the specified position even when it’s not directly inside the invisible barrier.

Out of curiosity, I have to ask why the barrier is on another layer. But besides that I’m not seeing where you’re saying in your conditions “Ball is inside this barrier and other conditions like mouse down etc” then do action “move to this position”. I just see, is mouse down, is barrier activated, ok then activate the barrier again and move ball.

But to be fair I haven’t used physics yet so my observation may be just ill informed.

1 Like

Hi there,

I’m not too sure what the logic is to determine if the ball is inside the barrier while the mouse left click button is being pressed to reposition it.

So far it’s just repositioning it every time the mouse is clicked.

I don’t want the ball repositioning if it hits the outside edges of the barrier, only if it is inside the barrier, even if it’s like a small one inch inside the barrier, it needs to reposition but otherwise it can be clicked and dragged freely without repositioning.

Well I’m not even sure you have to, maybe in physics behavior that sort of thing is just implied. I know in my projects I haven’t used physics yet and I have to tell it to do every little thing. Someone else on here will know for sure.

Is the barrier box shape or is it just a long sprite for the wall or what? If it’s a box you can probably use point inside object, unless that can’t be used in physics. But just my bumping you up like this will attract many people that know the answer.

1 Like

Hey there,

I’m not too sure what the point inside object does. Someone might be able to explain to me how that works if it’s the correct way to go for my specific issue. I believe it can be used with physics.

The barrier is just a sprite with the Physics 2.0 static property.

1 Like

Well, I can tell you one thing for sure before you start messing around with point inside - it is COMPELETLy different than regular collisions. I had some regular collision conditions in my current project and I decided I needed the collision mask for something else, so I changed them to point inside conditions instead. Whoa. Suddenly I’m having to add “repeat for each instances” and NOT instead of regular inversions. It just took me an hour to change like 4 events haha. You are forewarned…