'Asteroids' style movement with walls?

Get help using Construct 2

Post » Tue Jan 21, 2014 8:36 pm

Hey all, I have a quick question.

I've been trying to get an asteroids-style movement working with collision. I'm using custom movement so I don't have to do collisions myself. However, I can't really seem to get it working properly. You can see the crazy stuff that happens when you hit walls in this capx.

Any tips on how to fix this and achieve more reasonable collisions?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,689

Post » Tue Jan 21, 2014 8:46 pm

Whats wrong with the wrap behavior? That's how the original worked.

If not how about the bullet behavior? It does bounce.
Image ImageImage
B
169
S
50
G
174
Posts: 8,327
Reputation: 110,798

Post » Tue Jan 21, 2014 8:50 pm

Yeah, I tried doing the same by using the custom movement behavior, but couldn't get it to work either. Ended up using the bullet behavior, as newt suggested.
B
124
S
43
G
41
Posts: 849
Reputation: 28,235

Post » Tue Jan 21, 2014 9:57 pm

@newt it's not meant to be 'asteroids', that's just the way I wanted to describe the movement.

@andreyin I just tried using the bullet behavior/bouncing, but it's really disconcerting to control because of the fact that it just instantly changes direction on you. Not really an option, I'm afraid.

Ideally, it would behave identically to the 8-direction behavior when hitting walls (i.e. would slide slowly along a slightly angled wall, and could slide at full speed along a wall if the direction was correct.)
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,689

Post » Tue Jan 21, 2014 10:13 pm

I swear, I made this just the other day when I was teaching C2 and I went to all this trouble too (using all these behaviours and testing which would be best), but now I simply can't remember how I did it.. Now that you mention it, I remember trying to use the bullet behaviour and having the same problem.

Wonder if the collision in the custom movement is really broken or something though.andreyin2014-01-21 22:13:47
B
124
S
43
G
41
Posts: 849
Reputation: 28,235

Post » Tue Jan 21, 2014 10:20 pm

I guess you could do something like:
If ship is overlapping sidewalls
-if ship angle is between180-360), ship set y to self.y+1
-if ship angle is between0-179), ship set y to self.y-1

The top walls would be a bit more complicated like angle= -90 to 90 set x to x+1 blah, blah blah
Image ImageImage
B
169
S
50
G
174
Posts: 8,327
Reputation: 110,798

Post » Wed Jan 22, 2014 2:23 am

@newt perhaps I forgot to mention that this is just an example and in reality the walls could be at any angle.

@Andreyin haha, that's a pain :P If you remember anything I'd appreciate it!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,689

Post » Wed Jan 22, 2014 3:45 pm

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

Post » Wed Jan 22, 2014 5:23 pm

Simple add the bullet behaviour too ... just make its speed like 0.001 or something and the bounce works :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Wed Jan 22, 2014 5:29 pm

Nope, because it shouldn't just top you when you hit a wall - you should be able to slide along walls.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,689

Next

Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, gskunk, zenox98 and 57 guests