Overlaps at an offset.

For questions about using Classic.

Post » Fri Sep 25, 2009 9:23 am

How does overlap at an offset work?

I'm trying to simply make a NPC turn when he's close to a wall, but it doesn't seem to trigger every time. If the offset is increased to 10 it seems to work, but shouldn't it work with just 1?

http://dl.getdropbox.com/u/930918/Offset.cap

Of course there are other ways to do this, but i still would like to know exactly how it works.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Fri Sep 25, 2009 9:30 am

It's identical to moving the object the given number of pixels along the X and Y axes, testing an ordinary overlap, then moving it back again.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Fri Sep 25, 2009 10:23 am

So why doesn't it allways work? Is it because the plattform movement isn't testing every pixel and sometimes miss and then stopps before the next frame?
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Fri Sep 25, 2009 10:34 am

Think it depends how fast the object moves. If you just use +1 offset and your object moves more than 1 pixel per frame, then yes, you'll find yourself in a fix. Because by that time you are well within the wall already, as you turn around and check for offset, you are still inside.

To be safe, factor movement speed into offset value. Or just move the object just outside the wall before turning it. It looks like ramming into the wall, staggering and then turning around. :P
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Sep 25, 2009 11:46 am

I'll just use the "wall to the left" and "wall to the right" conditions for this.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest