'Asteroids' style movement with walls?

Get help using Construct 2

Post » Wed Jan 22, 2014 5:30 pm

euhh ... ok, bound by layout ?
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Jan 22, 2014 5:33 pm

I just checked yur capx, but its already doing what you said ...

edit:

hmm I did some test with your custom movement setup ... but its not reacting like expected ... dunno why.lennaert2014-01-22 17:42:10
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Jan 22, 2014 5:38 pm

Notice that if you run into a wall at an angle, it will shoot off in one direction, or just stop flat. Ideally it should slide along the wall depending on the angle of motion, just like the 8-direction behavior.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Wed Jan 22, 2014 5:46 pm

I just removed all your events, and tried with merely giving the sprite a car behavour or 8 direction behaviour, they both too slide along the wall, the 8 dir a bit less gracefull then the car behaviour, but thats related to the shape of your moving object.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Jan 22, 2014 5:56 pm

Neither of those behave the way I want ('Asteroids' style movement).
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Wed Jan 22, 2014 6:01 pm

[QUOTE=sqiddster] Neither of those behave the way I want ('Asteroids' style movement).[/QUOTE]

You can tweak that car behaviour a lot, its default looks a lot what you made with the custom movement.

Oh well, good luck :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Jan 22, 2014 6:25 pm

So the thread title should be "Asteroids style movement(ok not really), and oh by the way, the walls rotate for some unknown reason".

Yeah, um, none of the standard behaviors will work for that.

Try making your own with sin, and cos.
Image ImageImage
B
168
S
50
G
169
Posts: 8,280
Reputation: 108,189

Post » Wed Jan 22, 2014 6:35 pm

@newt the movement is asteroid-style, the only difference is it should have collision.
I never said the walls rotate, I just said that they can be at any angle.
It's also difficult to make it manually because there's no good way to test the angle of the wall you're colliding with.



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

Post » Wed Jan 22, 2014 7:06 pm

Its not much different than raycasting.
Image ImageImage
B
168
S
50
G
169
Posts: 8,280
Reputation: 108,189

Post » Wed Jan 22, 2014 7:49 pm

After fiddling with it a bit I don't find the custom behavior's push actions useful at all so I tried a few other methods. One that came to mind is to use the 8direction behavior instead and use events to set the horizontal and vertical velocities. It didn't work ideally since the 8direction often stops short of the walls if going too fast.

If you're fine using boxes with no rotation for the walls for now here is a capx. It uses a simplified case of the Separating Axis Theorem to do the push out and wall sliding. I was using it in another capx and found it to be a very clean way to do the wall sliding. I'll try to extend it into a plugin one of these days if I get time.
https://dl.dropboxusercontent.com/u/5426011/examples21/sat_push_aabb.capx
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: rayolf and 23 guests