'Asteroids' style movement with walls?

0 favourites
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • 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?

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

    If not how about the bullet behavior? It does bounce.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.)

  • 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.

  • 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

  • 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!

  • *bump*

  • Simple add the bullet behaviour too ... just make its speed like 0.001 or something and the bounce works :)

  • Nope, because it shouldn't just top you when you hit a wall - you should be able to slide along walls.

  • euhh ... ok, bound by layout ?

  • 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.

  • 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.

  • 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.

  • Neither of those behave the way I want ('Asteroids' style movement).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)