8dir-plugin collision-wall MAD animations

Get help using Construct 2

Post » Tue Aug 22, 2017 7:29 pm

Last I looked, the 8dir behavior collisions work like this:

Move the object with it's speed
if the object overlaps a solid then move it back to it's last non overlapping position and set the speed to 0

It's a valid way to do it, but it can cause it to stop short of the solid, then speed up again to close the smaller and smaller gap. Aka the effect you are observing.

So a more desirable behavior would be for the overlapping object to move flush against the solid before stopping.
Maybe by not using the solid behavior, and using the push out action of the customMovement behavior when overlapping the wall sprite or just doing your own push out with events. I think there have been some other topics with examples of a push out with events.

Another idea is to keep track if the object is moving or not over multiple frames and only change the animation if it has stayed the same over multiple frames. That should eliminate most of the flickering with the only drawback of causing a slight frame delay for animation changes. So for example if you keep track of 4 frames it could look like this:

global number f1=0
global number f2=0
global number f3=0
global number f4=0

every tick
--- set f4 to f3
--- set f3 to f2
--- set f2 to f1

sprite is moving
--- set f1 to 1
else
--- set f1 to 0

compare f1+f2+f3+f4 = 4
--- set animation to walking

compare f1+f2+f3+f4 = 0
--- set animation to stopped
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Tue Aug 22, 2017 7:46 pm

R0J0hound wrote:Last I looked, the 8dir behavior collisions work like this:

Move the object with it's speed
if the object overlaps a solid then move it back to it's last non overlapping position and set the speed to 0

It's a valid way to do it, but it can cause it to stop short of the solid, then speed up again to close the smaller and smaller gap. Aka the effect you are observing.

So a more desirable behavior would be for the overlapping object to move flush against the solid before stopping.
Maybe by not using the solid behavior, and using the push out action of the customMovement behavior when overlapping the wall sprite or just doing your own push out with events. I think there have been some other topics with examples of a push out with events.

Another idea is to keep track if the object is moving or not over multiple frames and only change the animation if it has stayed the same over multiple frames. That should eliminate most of the flickering with the only drawback of causing a slight frame delay for animation changes. So for example if you keep track of 4 frames it could look like this:

global number f1=0
global number f2=0
global number f3=0
global number f4=0

every tick
--- set f4 to f3
--- set f3 to f2
--- set f2 to f1

sprite is moving
--- set f1 to 1
else
--- set f1 to 0

compare f1+f2+f3+f4 = 4
--- set animation to walking

compare f1+f2+f3+f4 = 0
--- set animation to stopped


thank you very much for the great help, im actually avoiding the problem using 4 different (non solid) sprites for wall of the rooms, that system work decently, only thing is the problem with irregular wall position, for example wall at differents angle..
Image
B
13
S
7
G
5
Posts: 443
Reputation: 4,710

Post » Tue Aug 22, 2017 8:19 pm

Maybe more carefully placed walls? I haven't tried something like that.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Tue Aug 22, 2017 8:39 pm

R0J0hound wrote:Maybe more carefully placed walls? I haven't tried something like that.

You can try it yourself, voilà a sample capx..
https://drive.google.com/open?id=0BwNG7 ... GdOa21Pc2c
the player box overlap a bit the wall, but in the game i place the invisible wall a little further towards the inside of the room, so the thing is not even noticeable.
The problem I spoke to you is when I use sloping walls at various angles, in those cases I have not yet felt good how to do that.
B
13
S
7
G
5
Posts: 443
Reputation: 4,710

Post » Tue Aug 22, 2017 10:44 pm

There's no diagonals in your capx. Anyways the idea's only fault is how far you overlap the wall depends on the speed, which may or may not be acceptable for your purposes. I'd guess in general for any wall in your game you'd put those wall sprites around them. For diagonal you may need to put two of them. Like for a diagonal going down and to the right you'd put a bottom and left sprite along the top right of the sprite.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Wed Aug 23, 2017 8:20 am

R0J0hound wrote:There's no diagonals in your capx. Anyways the idea's only fault is how far you overlap the wall depends on the speed, which may or may not be acceptable for your purposes. I'd guess in general for any wall in your game you'd put those wall sprites around them. For diagonal you may need to put two of them. Like for a diagonal going down and to the right you'd put a bottom and left sprite along the top right of the sprite.

Yep, finally a person who understands the problem, and speech relevant/constructive suggestions.
I was not really looking for a universally valid method to deal with the problem, but right for the game I'm working on now, where Player's speed is constant and I can handle the size of the walls to dampen the sink due to the collision of the box if If it was too fast it would overtake it. The discourse of the diagonal walls is also correct, I had already thought of superimposing the two walls.
The only fact is that I have to fill the layout of these overlapping sprites along the walls, so I was wondering if anyone found a simpler way, that "push out action" of the "customize movement" behavior you talk you think is simpler?
B
13
S
7
G
5
Posts: 443
Reputation: 4,710

Post » Wed Aug 23, 2017 5:51 pm

I don't really have a simpler way per say. I actually don't use the customMovement's push out. Here is the push out/solid replacement I've come up with that works much better:
how-do-i-make-the-8-direction-behavior-slide-against-wal_p904925?#p904925
There are a few variations and although the logic is complex it should be usable by just copying it over.

They don't touch the speed of the object but here's a way to just measure how fast the player is moving and use that for seeing when it's stopped:
https://www.dropbox.com/s/fuly7efud7rvd ... .capx?dl=1
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Fri Aug 25, 2017 10:27 am

Just posting in here to remind everyone please to keep things civil - there is no need for personal attacks. Thank you everyone!
Image Image
Scirra Founder
B
175
S
41
G
34
Posts: 4,386
Reputation: 54,242

Post » Fri Aug 25, 2017 3:10 pm

R0J0hound wrote:I don't really have a simpler way per say. I actually don't use the customMovement's push out. Here is the push out/solid replacement I've come up with that works much better:
how-do-i-make-the-8-direction-behavior-slide-against-wal_p904925?#p904925
There are a few variations and although the logic is complex it should be usable by just copying it over.

They don't touch the speed of the object but here's a way to just measure how fast the player is moving and use that for seeing when it's stopped:
https://www.dropbox.com/s/fuly7efud7rvd ... .capx?dl=1

Admirable ... you are undoubtedly a pro!!
Yours that is a job up. Works perfectly, it ALSO PASSED the test of 1/2 pixel space bug that affect the "normal" 8dir collision behavior ( player-box-collision-issue_t192298 )!!!
Thanks a billion and so many compliments really..

Tom wrote:Just posting in here to remind everyone please to keep things civil - there is no need for personal attacks. Thank you everyone!

sorry sir :roll:
B
13
S
7
G
5
Posts: 443
Reputation: 4,710

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests