K
KingSolomon
Guest
GMS2 v 2.1.5.332
I am trying to make a feature where the player character can grab a solid object above them, and if it is moving the player will move with it.
my code never lets the player collide with a solid object, I have been trying to get the object using instance_position, but it never appears to find the object, the id returned ends up being -4 every time and the game crashes.
I am trying to make a feature where the player character can grab a solid object above them, and if it is moving the player will move with it.
my code never lets the player collide with a solid object, I have been trying to get the object using instance_position, but it never appears to find the object, the id returned ends up being -4 every time and the game crashes.
//getting the object
if roofGrabActive {
//change vertical position
if isRoofWalking {
//change horizontal speed
if isRoofWalking{
Thus far i have tried using instance_nearest as well, although i fear that would get me some glitches in the long run, but I run into the same problem. This leads me to think I have a basic misunderstanding of what an 'id' is or something, and I haven't been able to figure out what i'm not understanding by looking through the manual.if roofGrabActive {
if (place_meeting(x,y-1,solid)){
}isRoofWalking = true
roofGrabbed = instance_position(x,y-1,solid)
}roofGrabbed = instance_position(x,y-1,solid)
//change vertical position
if isRoofWalking {
if !place_meeting(x,y-1,solid) {
}isRoofWalking = false
roofGrabbed = noone
} else {roofGrabbed = noone
currentVSP = 0
// this crashes the game due to the object being unknown, and therefore does not have a y valuey = instance_id[roofGrabbed].y+1
}//change horizontal speed
if isRoofWalking{
// I expect this would crash it to if i could get to it.
currentHSP += roofGrabbed.currentHSP
}currentHSP += roofGrabbed.currentHSP
Last edited by a moderator: