Not allowing me to compare x-position of two objects!

Hello! I’m getting into game development, and I’m really… REALLY new to it. I don’t wanna complicate myself much with a ton of variables off-the-bat, so I’m trying my hardest to limit adding them.

I’m currently trying to make grid-like movement, and I’m using a system that takes advantage of sprite *points *in order to allow for fixed distance movement. There are points situated by each of the 4 possible directions, and those are used in order to detect if the game should allow you to move or not.

When the player clicks on the right key, it checks if the right point is situated on a tile you can move on. If it’s true, then an object (called MovementCalc) is placed exactly where the player should be stopping. Now everything I’ve said so far works exactly how I would’ve wanted, but here is where the problems come in.

In order to make the character stop, I wrote in code that basically says “When both the character and MovementCalc’s x-positions are the same, then stop all movement”, but literally no matter what I do, it just doesn’t work. The character never stops, even when the equals sign is changed to greater than. If anyone can look at my code and help me figure out what’s being weird, that would be greatly appreciated… :sweat_smile:

pull in the sub-event in the main “column”. because as a sub-event it will trigger only when the main event is executed. see Wiki.

1 Like

pull in the sub-event in the main “column”. because as a sub-event it will trigger only when the main event is executed. see Wiki.

Thanks for the suggestion @Gyuszko ! Sadly, this didn’t seem to fix my problem… It seems like nothing in the action area is activating no matter what I do.

hmm. I can’t see what is wrong. a few ide what I would try: when compare two positions, always use “greater than” instead of “equal”. if position comparsion isn’t give the desired result, try collision detect or something else. don’t stick to what doesn’t work.

1 Like

Yeah, nothing seems to be working out… If anyone would like to see this problem first-hand, I’ve linked the project here. Maybe someone can help me figure this out.

http://www.mediafire.com/file/4yfhjtqdo0dp0hi/RightMovement.zip/file

the trouble was you didn’t listen to me.

by the way I replaced the “compare X positon of an object” to “compare two numbers” because when compare positions the origin point is authorative, but I want compare the center points.

1 Like

I didn’t send you the version where I tried what you told me to do, but I did try it out. I even wrote in the initial thread post “The character never stops, even when the equals sign is changed to greater than.” Sorry about that… When I get home, I will try out what you posted. Thanks a ton!!

1 Like

then something very special could have happened because at first I just set the equality sign to greater than, and it worked for me right away. I only switched to this solution because the sprite didn’t stop in a completely good place.

1 Like

Thanks a ton for your help!! It finally works now. :slight_smile:
Although, while I was testing things out, my character often stopped a pixel or two out of place. But don’t worry, cause I fixed this by teleporting my character to the exact position of MovementCalc in order to center it, then deleting MovementCalc.

Again, I can’t thank you enough for your help. :heart:

I’m gald to hear this. so, if your problem is solved, please mark thread as “solved” like others.