What I’m trying to do:
I’m making a draggable object (BookSprite). When you click the object, it immediately appears in your inventory at the bottom of the screen. You can drag it from your inventory and onto the screen. When the object is in collision with another specific object (Locked), both objects are supposed to disappear. If the objects aren’t in collision, then the item returns to it’s previous position.
When BookSprite is in collision with Locked, the objects don’t disappear and BookSprite returns to the inventory.
Are they supposed to disappear once you release the mouse and move the mouse off BookSprite, or when they collide while BookSprite is being dragged?
If it’s while BookSprite is being dragged, then why don’t you use the “Being dragged” condition on BookSprite, rather than checking if the cursor/touch is on it?
It’s supposed to disappear when I release the mouse and move the mouse off of BookSprite.
Hmmm. I can’t replicate what you’re experiencing. Do you have any other behaviours on the objects, or any other events that reference BookSprite?
Can you turn on debugging to check the collision boxes are where you expect them using this action :
I enabled debugging, but I didn’t see anything off. Both objects had collisions.
The Mansion is the only area that references BookSprite. The only Behaviour BookSprite has is Draggable. No variants or other behaviour
I’ve tried other things, like cutting the condition where BookSprite isn’t in collision with Locked. Booksprite just sits on top of Locked and neither get deleted.
I recorded a video to show what’s happening when I run the Vertical Slice. Debugging is enabled and if that looks confusing, I can take another video without the debugging and collisions shown.
Do collisions only work if they’re on the same layer? I’m asking because BookSprite is on the GUI layer and Locked in on a different layer. I don’t think I could put them on the same layer, though
Ahh. Has one of the layers moved? If so, then that’s what’s causing the problem.
They’d still collide event if on different layers. But that’s determined by their positions in the layer, not their placement on screen.
Imagine the camera centred on both objects, Lock and BookSprite. If Lock moves to 1000,1000 and BookSprite is at 100,100, they won’t collide. But on the screen they both appear in the middle and one on top the other because the cameras for each layer is centred on each object.
Why not? There’s a small calculation to make to get the differences between layers if one of the layers has moved. I can help with that if that’s the way you’d like to go.
So the problem could be their positions, not the collision layers. Yeah, I need help with this. What’s the small calculation?
To answer your question, I can’t put both objects on one layer because when I’ve tried, one or both objects disappear. This is because the GUI layer (with BookSprite) is static, while the Doors layer (with Locked) is a layer that moves. It has the Center camera layer Action.
If that’s the only problem, then the solution can be simple and you can move it from one layer to another.
You calculate the offset of the BookSprite from the GUI camera, and when you change layers, apply that offset but from the Doors camera.
So move the BookSprite to the Doors Layer, and set it’s position with :
Got this message and I’ll try it now.
I tried that and BookSprite doesn’t show up in the inventory when it should.
EDIT: I forgot to add a couple of spaces in the code. One sec.
EDIT2: Nope, still not working. It appears at certain position in the level outside of the screen, not on the screen like it should.
EDIT3: I’m wondering if the Create action right above is interfering, so I’m gonna play with that for a couple of minutes.
EDIT4: nvm, that didn’t work either.
I found the solution! Gimme a few minutes to fix up my programming and type it out.
So I looked over Mr. Men’s instructions again and I misunderstood a step. The step was the Action to move an object from one layer to another. I placed that in the BookSprite is being dragged Condition. With this, I can have the sprite show up in the Inventory Space at the bottom of the screen on the Inventory layer - and then move it to the Doors layer with the Locked object so they can collide and finish the mechanic process.
I also had to make sure to place the Move Layer action on the Not Being Dragged condition. This way, BookSprite returns to the Inventory layer and at it’s previous position when it’s not being dragged.
Thank you for all your help, Mr. Men. I couldn’t have solved this without you.