How stop Custom Movement when it reached the position

Get help using Construct 2

Post » Sun Oct 15, 2017 7:46 am

Hey
I want move menu object from left to right in the stary of layout. I tried use 8 direction but it won't work when got solids on his road. What is the best method for moving an object from left to right.
Now I trying Custom Movement but object wan't stop when reached the position.

This not work, it won't stop:
Image
B
10
S
4
G
2
Posts: 199
Reputation: 2,386

Post » Sun Oct 15, 2017 9:18 am

X and Y coordinates almost always will be in fraction of a pixel, for example x=49.028388481, y=432.1493800217

You should try something like this:
System -> Compare two values -> Distance(sprite.x, sprite.y, 49, 432)<2


Also, check the MoveTo plugin:
behavior-moveto_t63156
It's easy to use (easier than custom movement) and I think it has "On reached destination" event.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
126
Posts: 1,743
Reputation: 67,307

Post » Sun Oct 15, 2017 10:44 am

dop2000 wrote:System -> Compare two values -> Distance(sprite.x, sprite.y, 49, 432)<2.

@dop2000
Eh it not working, I think it should be something simple to fix this.
Now I stopped it using "wehen overlapnig another object" but it's littel tricky ;-)
Last edited by marcinkowski on Sun Oct 15, 2017 10:58 am, edited 1 time in total.
B
10
S
4
G
2
Posts: 199
Reputation: 2,386

Post » Sun Oct 15, 2017 10:50 am

It should be working, maybe it's off by more than 2 pixels.
Also I mixed up x and y in my previous comment.

try
Distance(sprite.x, sprite.y, 432, 49) <50
If it works, try <20, then <10

Or use MoveTo plugin.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
126
Posts: 1,743
Reputation: 67,307

Post » Sun Oct 15, 2017 11:06 am

dop2000 wrote:It should be working, maybe it's off by more than 2 pixels.
Also I mixed up x and y in my previous comment.

try
Distance(sprite.x, sprite.y, 432, 49) <50
If it works, try <20, then <10

Or use MoveTo plugin.

@dop2000
I gave <10 and it's work Perfect ! thanks much man!
B
10
S
4
G
2
Posts: 199
Reputation: 2,386


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests