Regions collision detection issue

Started by AnasAbdin, Mon 12/10/2015 16:01:53

Previous topic - Next topic

AnasAbdin

I'm trying to make a character do something when stepping into a region. In theory this should work perfectly. But practically and under the conditions I'm using this is not the case. It works sometimes; and doesn't work in other times...

AGS version 3.3.3, December 2014
The game is 320x200 32 bit
The character is 5x5 pixels
Tween module v2.0.1 by Edmundo Ruiz et al. (I'm using the EaseOutSineTween)


-Sometimes the character moves (NoBlock) into the region without any reaction. When he stops completely the region's 'belated' action is executed.
-Sometimes the character ignored the region completely

For the first case, I suspected that the tween module might have been the problem, specially that I'm using an EaseOutSineTween which tends to slow down the movement towards the end right before stopping completely. Yet still when the character is at the beginning of his movement he can ignore the region completely.

The region is about 100x30 pixels which is quite large for the little 5x5 character to be detected. But even though, I still have to create 1 pixel thin regions for later. Is this going to be a problem? Should I consider using objects instead? If so, will they collide better?

Thanks ???

Slasher

#1
Hi

i can't speak for ags 3.3.3 / Tween module v2.0.1  but i had this problem once. it was to do with the amount of pixels between char walking frames. it sometimes missed the regions commands. i had to look into char walk spd / ani delay to solve it.

secondly i find object collision a good way as an option.

hope you get it sorted ;)




AnasAbdin

Thanks slasher...
I tried colliding with objects a while ago and it got worse :~(

note the I'm using Move not Walk

Slasher

Are we actually just talking about char 'walks-on' region?

AnasAbdin


Slasher

What about if char at x y do this....?

MiteWiseacreLives!

Try using char.stopmoving (stopanimatng??) at the start of the region script. I have had this problem before myself, can't quite remember but I think you have to interrupt the walk to command.

AnasAbdin

The first command in the region script is character stop moving :-\

Slasher

may i ask why you use move (assuming it's an charater) ?

AnasAbdin

It IS a character. I'm actually using cEgo.TweenPosition to benefit from the EaseOutSineTween.
I tried 'walk' but still had the same problem.

MiteWiseacreLives!

Quote from: AnasAbdin on Mon 12/10/2015 18:10:41
The first command in the region script is character stop moving :-\
Yah the region thing can be sloppy, that sucks. Do what Slasher says and make your own region, in rep_ex check char x y (make a box). If that still messes up, try rep_ex_always something is taking priority over your region.

Slasher

#11
TweenPosition is ok for gui's and stuff, but is it really needed for your character in this inst? unless there is good reason?

it seems that you are going the hard way around something very basic.

Its also hard when you can't see it in action...

Khris

Each frame, assuming the game is not blocked currently, AGS will read the pixel color at the character's X and Y of the region bitmap. This will return the region index, and trigger the according event.
Which means if the character moves blockingly, and/or moves far enough in between frames so a region pixel isn't occupied, nothing will happen.
Crossing a one-pixel region will not work reliably and is best solved by simply turning one of the bordering areas into a region, then waiting for steps onto / steps off.
(Decreasing the Movement Speed (= pixels moved per walkcycle frame) is a bad idea, since it should be synced to the walkcycle animation to prevent moonwalking / gliding)

It's easily possible to "fix" the region system by using something like
if (Region.GetAtRoomXY(player.x, player.y) == region[2])
inside repeatedly_exeucte and triggering the event in there.

SMF spam blocked by CleanTalk