SO I am trying to create a S’more game where you can snap the marshmallow to one of the sticks:(they are all generated during the game)
if Marshmallow is in collision with stick, and if touchpad/mouse is released, and if there’s no marshmallow on it, then it will change the marshmallow position to the stick pointX,Y and tween a little.
but the result is:
when I have more than one stick and marshmallow, when the first one is snapped on one of the sticks, even if I put the second marshmallow on second stick, it will transport to the first stick and overlay on the first marshmallow…
I tried everything including the sub event.
I mean theoretically the marshmallow should be only interacting with the collided stick?
help…
It’s checking if the stick has a marshmallow but not which marshmallow is being dragged. So, all of the marshmallow objects will be used in the actions.
How are you dragging the marshmallow? If it’s with the drag behavior then you can use marshmallow is being dragged as a condition. If not, you’ll need to use another condition like pick the nearest. It depends on how you’re moving the object.
Checking the value of the stick boolean before the collision check would also ignore collisions between those sticks.
1 Like
solved! thank you Keith, here’s the result, although the tween when pick up the marshmallow on stick doesn’t work too well but I’m happy for now, will take some more time to polish it.
of course if there’s a better way to do it please let me know!(I guess I am making it too complicated)
1 Like
I would start with the dragging. That will pick the marshmallow. Then check the boolean for the sticks so it doesn’t pick a stick that already has a marshmallow. Then check for marshmallow collision with stick. If there could be multiple sticks then you would need to pick the nearest stick.
Marshmallow is dragging or dropped
Stick boolean is false
Marshmallow collision with stick
Pick nearest stick from either cursor or marshmallow x, y
Conditions work like filters. Without a condition all objects get used. Each condition filters the pick list. The next condition filters the list further. As long as at least 1 object remains then the actions get triggered and the picked objects are used or all of the instances if there aren’t any conditions for that object.
The sequence matter.
You might start with 10 sticks and 10 marshmallows.
The dragging or dropped reduces it to just 1 marshmallow.
The stick boolean check might reduce the sticks to 8.
The collision might reduce the sticks to 1 or 2 sticks.
The pick nearest will always reduce it to 1 as long as there is 1 left
1 Like