Asteroids style movement with collision-revisit

Get help using Construct 2

Post » Sat Jul 19, 2014 1:00 am

Hey all,

A while ago I posted a topic about getting an 'asteroids-style' movement to work with a robust collision system. I eventually came upon a solution which I was happy with but its fundamental flaw has become too problematic.

Here's the capx of that solution. Basically, I use some trig and raycasting to find the angle of the nearest wall, and push off it opposite that angle. It works terrific for all outwards angles. However, as you can see, there are a lot of problems with inwards facing wall angles. On angles between 180 and 90, the player twitches and shakes, and on angles between 90 and 0, the player teleports away and disappears. This isn't unexpected behavior for the code I'm running (read: I'm not asking anyone to fix my bugs!) however I've spent hours trying to come up with a solution to no avail.

So, does anyone have any ideas?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Jul 19, 2014 7:00 pm

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

Post » Sat Jul 19, 2014 7:20 pm

Could be that angle() doesn't know which direction you are coming from ie angle(x1,y1,x2,y2) is different than angle(x2,y2,x1,y1).
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sat Jul 19, 2014 9:28 pm

@newt did you look at the capx? I don't once use angle() in the collision code...
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Jul 19, 2014 9:59 pm

Technically you're correct.
Image

You used it twice. :P
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sat Jul 19, 2014 10:36 pm

Ehh its hard to tell whats going on with the custom movement mixed in.
I haven't used it in C2 much, and the angle(0,0,x,y) just doesn't seem right.
Surely you have a better way to get that angle.

Anyway, good luck.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sun Jul 20, 2014 12:20 am

@newt that's just the movement code! it's not even relevant to my question :P
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sun Jul 20, 2014 2:09 am

Edit.
Never mind, Im sure you'll figure it out.
I didn't have that much motivation to help in the first place, and even less now.
My apologies.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sun Jul 20, 2014 4:55 pm

@Newt all right, that's fine of course :)
If anyone else has any ideas I'd be super keen to hear them!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Mon Jul 21, 2014 6:44 pm

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

Next

Return to How do I....?

Who is online

Users browsing this forum: DharmaOne, namaewayukidesu and 14 guests