Forum Discussion

ReggieJose-f8d8's avatar
ReggieJose-f8d8
Community Member
9 months ago

Object disappearing when swapping from one motion path to another

I'm unable to determine why this object is behaving the way it is (project attached).

I have an object on a downward motion path ("falling"). When it hits the bottom, it changes the motion path (variable triggered on intersection, change motion path to "stop"). However, when I attempt to change the motion path using a different motion path ("jump"), the object disappears entirely. If I inactivate the "falling" motion path, I can make the object "jump" over and over. If I "jump" from "stop", it works as intended, only causing issues when attempting to "jump" once more (as it is then in the "falling" motion path due to a variable).  

I would like the object to move up when "jump" is active and move down when "falling" is active, but the object instead disappears. 

  • EmmaKavanagh's avatar
    EmmaKavanagh
    Community Member

    Hi Reggie. The problem is being caused by the length of your falling motion, as when you press space to jump the object moves to the end point of the falling motion and then jumps from there. Because you've made the falling motion long enough to fall from the top to the bottom of the screen, when it falls from lower than that all subsequent motions all happen below the visible screen. 

    What you can do is set the motion to be very short and then have it repeat, and another variable that changes when the object intersects with your rectangle at the bottom of the screen, so what you end up with is a trigger that says 'move object along falling when falling stops, unless 'object intersecting with bottom of screen trigger' is true. That way it will continue to fall until it reaches the bottom rectangle, then stop. You can use a similar trigger for the top of the screen, disabling the jump if the object is intersecting with the top of the screen so you can't jump out of screen. 

    This is super hard to explain, so I've attached an edited story file so you can see how the triggers and variables might work. 

  • EmmaKavanagh's avatar
    EmmaKavanagh
    Community Member

    This one is confusing. I've tested in your file, and can see what you mean re triggers breaking. I tried changing the oval to a group (so it's three items moving along a motion path as a group rather than using states) but then the whole screen was blank when I tested - not even the rectangle at the base of the screen. So weird. Grouping the items in the jump and fall states seemed to help in your 'not working' slide - but both 'wings' appeared behind the oval in test regardless of them being placed in front in the state. All very strange. 

    I have found a potential work around for you. Instead of using an oval and two triangles, create both versions of the shape in ppt and save them as images. When it's only one object changing and not adding in additional objects in the states it seems to work fine. So instead of the shapes, you essentially have an image with two states - one with wings up and one with wings down. You can then set the states to change when your 'IsFalling' variable changes to true or false. That seemed to work for me. 

  • Thank you Emma, this makes perfect sense. I hadn't realized it would jump to the end point and assumed it stayed where the current location was in the path. Thank you! :)

  • If I could pick your brain on this same project (I can open a new discussion if that's more appropriate). 

    Your suggestion worked perfectly, but now I've run into a different issue. When I attempt to add additional states to the oval, the associated motion paths and triggers aren't firing correctly, even though the other states aren't being called. I assume this has something to do with changing states acting like different objects but I'm not certain how to wrap my head around a fix.

    Expected outcome: ability to change visual state when oval is moving up and when oval is moving down. 

    Updated project attached. I've removed the triggers for changing the state to show that the issue occurs even when nothing calls the states. 

    Edit: It seems to work as intended for the example you provided. Must have to do with using the variable as the controller. So you already solved this one, Emma!

    Edit 2: I came back to this and replicated the same issue with your version, but determined the cause... a shape added behind the oval. If I place anything back behind the oval in the additional states, it breaks the triggers. Very odd behavior. This also happens if I try to hide the base objects by turning its transparency to 100% (that actually breaks the whole slide and nothing will load at all).

  • Thank you for your continued testing! I had the same issues you outlined, very odd indeed. But yes, you are right that it seems to work as intended with just a sprite change and no additional objects. That works great for my purposes. :)

    I appreciate you tinkering with this!