Okay so i have this board and some marbles. The marbles are draggable and you put them in a slot after you roll the dice, the issue i have is that i need the marbles to only be placeable in the circle holes and no where else. I could really use some help with this, been stuck on this for 2 days.
Make a blueprint MarbleSlot with sphere collision, place instances of this blueprint in every hole
When pressing on the marble, start dragging which means: store its current position as PrevPos and make it stick to the cursor from now on
When releasing the mouse while dragging a marble, stop dragging and check whether the marble is overlapping any of the MarbleSlot actors and if so and the slot is empty, snap it to that actor. Otherwise, place it back at PrevPos.
This is a very broad description, but hopefully it helps.
Okay so what i have now is not working, its not detecting that its overlapping the collision and prints null every time. To make sure its not working i set true to set actor location to some cords and it still prints null.
I made a blueprint actor with just a sphere collision that fits a bit around the hole on the board. I am usuing the marble blueprint to check if it is overlapping the holecoll(the collision sphere actor). So 2 different blueprints.
Ok, you need to get a reference to the holecoll somehow, I’m not sure if this works, but it’s fast & worth a try: Make a variable in your marble BP, and just call it Holecoll Reference or something, and make it of type actor, and then set it’s default value to the holecoll BP. Now link this variable to the ‘Object’ on the cast. And then link up the cast to the execution nodes before the branch, so it flows from whatever is before, to the cast, to the branch. Now drag a wire from the ‘As Holecoll’, and do get actor world location, and then set your marble location to that value if the overlap is true. The only part about this that I am unsure about is that it will work to use the variable you made as a reference, otherwise you’ll need another way to get a reference.
Hmm… Okay just delete the variable, but keep everything else. Variable won’t work, I just tested something similar on my end. I think I know a solution, just drag the ‘On Actor Begin Overlap’ event somewhere, and then cast to the Holecoll, and use the ‘Other Actor’ as the object, and then make a variable OverlappingHoleLocation or something, and set that location.
So here’s how it should go: Actor Begin Overlap -> Cast to HoleColl -> Set OverlappingHoleLocation (using Get Actor World location of the ‘As Holecoll’ for the value). And now when you set the marble location after the branch, just use the OverlappingHoleLocation as the location. As far as your branch goes, here’s a solution: For the Actor Begin Overlap, after you set the variable, set another variable (isOverlapping) to true, and then on Actor End Overlap, just set it to false. And check for this variable in your branch.
So i started with the whole layout of the drag and drop of the marbles in the marble blueprint. On the release event it checks to see if the marble(referenced in the on release function) is overlapping, if it is set it to the location of the sphere collision. That is pretty much it and suprised it took me so long and so much help to realize how to do this.