# Asteroids style movement with collision-revisit

Get help using Construct 2

### » Thu Jul 24, 2014 5:04 pm

*bump*
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,729

### » Thu Jul 24, 2014 5:54 pm

I think you'll probably need to consider more than just the one closest wall. One works good like you said for outward angles, but for inward corners you could use the average of the two wall's angles as the angle to push out. Or you could pick the two walls in order of closeness and push out of of each one at a time. Of course with that you'd need to make your own "push out" events.
B
94
S
33
G
125
Posts: 5,458
Reputation: 79,979

### » Thu Jul 24, 2014 6:18 pm

@R0j0hound - thanks for having a look. I agree with you there - I toyed with finding the average of the two angles and pushing out, but you run into lots of little problems in things like narrow passageways and such.

Pushing out of two walls sounds interesting - Are you suggesting doing something at the instance level of the walls (i.e. pick a certain wall instance to push out of) so that I know when I'm done pushing out of one and I can deal with the other?

hmm... I could definitely give that a shot. What if I cast out like 16 or 32 rays around the player, see which of those rays collide with a solid, build a list of those solids along with the corresponding ray angles, maybe get rid of duplicates, then go from there?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,729

### » Thu Jul 24, 2014 6:27 pm

I was about to say the same thing as R0J0hound.

Probably what is happening is that by only considering one wall the player is pushed into the opposite wall, and on the next frame pushed further into the previous wall, and so on... so it spiral out of control.

I think one way to solve is to instead of generating a push out angle, generate a vector that represents that angle (x,y), and then you just need to sum all the vectors of all the overlapping walls to get the resultant push out angle.
Scirra Employee
B
163
S
55
G
17
Posts: 711
Reputation: 18,277

### » Thu Jul 24, 2014 7:18 pm

@Animmaniac that's a great idea actually - very similar to what I've been doing, but I really like the vector sum idea.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,729

### » Thu Jul 24, 2014 7:51 pm

@annimaniac @r0j0hound OK, the vector solution has helped a ton - now there's no 'teleportation' issue at all. There's still vibration however, and I'm not exactly sure how to go about fixing it. I'm playing around with it now.
You do not have the required permissions to view the files attached to this post.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,729

Previous