[Solved] Object disappears based on random position

I am working on a project that has an aiming feature like in the 2d metroid games. you hold down right click, the character points their gun in the direction of the cursor.

As the character setup, I have a player character object, an object that represents the arm of the character (this is controlled by a “change the position” and a “rotate to” event, set to the position and angle of the player character object.) and finally, the offending “gun” object.

This object has five events associated with it; showing and hiding the object when right click is held, setting the animation to zero when right click is pressed, and following a point on the visible “arm” object. I have double and triple checked these are the only events associated with this object. The problem is it does not render when the player character reaches an X value of around 4220.

I say “around” because the exact value seems to change each time the game is run. Once I reach that value, the object appears to stop rendering. It’s still there because it still fires bullets from where it “should” be, even while invisible, and it shows back up once I go back below X 4220. I know it’s based off of the position of the player character and not the gun animation because since the gun object is held at an offset I can wave it back and forth over this line with no issue. This also occasionally happens with the Y value, but less reliably (my favorite kind of errors are the ones that aren’t replicable 100% of the time). the 4220 X value is just the most common X value for the object to be hidden. In the included gif, it happens around X 800.

I tried using the “put object around a point” event instead, and still had the issue, however putting the object around the CURSOR location does NOT hide the object. Sometimes, it even just works like it’s supposed to. I have tried disabling all of the objects logic individually and it is the “change the position” event that seems to be the problem (it is not the “hide object” event the object has, this happens when the event is disabled). This happens in an empty scene with only the player objects and a floor to walk on
ooby
.

This is a bit frustrating as the exact details of what at this point I assume is a bug change seemingly randomly. Sometimes if I toggle the event that controls the position and angle, it “fixes” it, having the object work as intended until it decides not to work again.

ooby2

In this gif I have completely removed the “hide object” and “show object” behaviors. this was taken right after the first gif and that small change made it so it happens at around X 6000 instead. Notice how it cycles the animation to frame 0 as it becomes visible again! The events are set up so it does that when I press right click, so that means that it is in some sort of weird quantum superposition rather than just being invisible because it’s not playing animations.

ooby3

This gif was taken immediately after the second one. In this gif, the object works as expected, moving the player object across the X6000 mark does not vanish the gun object. The only thing I did to this object between the gifs was disable and then re-enable it’s events.

Any help would be appreciated!

Just checking back in with an update, I tried remaking the object from scratch and still had the same problem, but remaking it a THIRD time, with all of the same logic and animations removed the issue.

I encountered the same problem with my gun object with similar behavior, did you solve this problem?

You can try making a new topic