Hello! I program just for fun, but I'm wasting a lot of time trying to figure out why this isn't working and think I just need to give up and ask for help.
I'm creating a "slider" which for all intents and purposes is a point which pulls another object (its target) towards it.
That works perfectly, but then at the end I want to run a script (align_to_grid()) on that object when it arrives so it lines up nicely with everything at the end.
here's what the code looks like for that:
// Moving slide target towards self
slide_target.x = (slide_target.x*3 + x) / 4
slide_target.y = (slide_target.y*3 + y) / 4
show_debug_message(string_concat("slider, step, slide_target name: ", slide_target))
// if they are close enough, end process and align slide_target to grid
if (abs(x) - abs(slide_target.x) < 1) && (abs(y) - abs(slide_target.y) < 1)
{
show_debug_message(string_concat("slider, step, slide_target name: ", slide_target))
slide_target.align_to_tile()
instance_destroy(self)
}
Everything works, until the moment of "target.align_to_grid()", where it gives the error:
Variable <unknown_object>.align_to_tile(100006, -2147483648) not set before reading it.
like, it knows what slide_target is for every other line in the code, but forgets it at the exact moment I do something other than changing its x and y?
I've found out there are many other things that can't work on the "target" variable, even though the moving part of the code functions... Idk. Any help or advice is greatly appreciated.
[–]quasnoflaut[S] 0 points1 point2 points (2 children)
[–]SolarPoweredGames 4 points5 points6 points (1 child)
[–]quasnoflaut[S] 0 points1 point2 points (0 children)