GameMaker [SOLVED] Collisions with a spriteless object

S

Spencer S

Guest
I have 2 objects: obj_player, and obj_pickup. obj_pickup is a spriteless object that I assign a sprite to in the objects creation code in the room. In this tutorial
, it has just that: a spriteless object that is assigned a sprite later on in the creation code. That way, one object can be used for a multitude of different items.

The one key difference is that in that tutorial, physics is NOT enabled, and in my game, physics IS ENABLED. Unchecking physics and using the exact same code otherwise allows the obj_pickup to collide just fine with obj_player. But the moment I check physics on, the collisions don't work, even if I use mask_index, which I thought would set the collision mask correctly. What is going wrong?
 

FrostyCat

Redemption Seeker
You have to remember that turning on physics shuts down traditional movement and collision-checking. This includes sprite-based collision masks and all conventional collision-checking functions (e.g. position_meeting(), place_meeting(), etc). You have to use a genuine collision event (i.e. the kind selected from the event dropdown) or check using physics_test_overlap() instead of what the video shows. You can't just copy code out of context without understanding it and expect it to work.

Also, before you turn on the physics system, read this article and carefully reconsider whether you genuinely need it on. Having it on for projects that aren't based on Newtonian physics can waste more of your time than it saves. Particularly, if you are turning it on based on HeartBeast's RPG advice, STOP IT. A lot of responders around here are at their wit's end when it comes to cleaning up after that one tutorial.
 
S

Spencer S

Guest
Holy cow, thanks a ton. I'll read up, and probably change my system. Thank you!
 
S

Spencer S

Guest
I did watch HeartBeast's tutorial and that's the sole reason I'm using physics at the moment, but my game isn't based on any physics heavy mechanics, so I'll most likely get rid of it.
 
Top