How do I make a sprite move on walls and ceilings?

0 favourites
  • 4 posts
From the Asset Store
Wall Pin Board is a hyper causal game developed for fun and inspired by YouTube video whose link is given in description
  • I'm working on a Mega Man like game and I wanted to do an "armadillo" boss that can roll around the room that the fight takes place in, stopping on occasion to fire from a turret. I've tried a number of different hacky solutions, but I still can't figure out how to make this work. I'd like to be able to make him move left/right relative to wherever he is (so if he's on a wall and I tell him to move right, he moves up/down accordingly) and stop on occasion without dropping.

    I've included a sample capx to give you a better visual of what I'm trying to do. Basically I just want the red box to move seamlessly across all the blue surfaces.

    dl.dropboxusercontent.com/u/1108862/armadillo.capx

  • You could use the platform behavior to do it quick.

    every tick:

    --- simulate platform pressing right

    sprite: wall to right

    --- set angle of gravity to self.platform.angleofgravity-90

    you just need to eliminate the corners that it can get caught on.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use the platform behavior to do it quick.

    every tick:

    --- simulate platform pressing right

    sprite: wall to right

    --- set angle of gravity to self.platform.angleofgravity-90

    you just need to eliminate the corners that it can get caught on.

    Hey, that's exactly what I was looking for! Thanks!

    How would you recommend smoothing out the corners? In my current design, they're just 45 degree slopes. It seems to work pretty smoothly for a while, but eventually it'll randomly get caught and stop.

    I'm also trying to figure out how to set it's angle so it's flush with the wall it's on...I tried "On collision with wall > set sprite angle to wall.bossAngle", where bossAngle is the appropriate angle set to each wall individually. This also works most of the time, but I don't think it always checks the collision or something, cause it does get caught on some angles more than others.

  • To eliminate the sprite getting caught you need to lengthen the slope sprites. If you look close as it is now they don't extend far enough so there's corners to catch on.

    An overlaps check could be better than a on collision check. Just keep in mind you could overlap more than one wall. One way to deal with that would be to use the average angle of the wall's bossAngle.

    +------------------------+
    |                        | set sprite angle to 0
    +------------------------+
       local number count=0
       local number sum=0
       +---------------------+
       | sprite overlaps wall| set count to wall.pickedcount
       +---------------------+
          +------------------+
          | for each wall    | add wall.bossangle to sum
          +------------------+
          +------------------+
          |                  | set sprite angle to sum/count
          +------------------+[/code:3kmqslf2]
    
    The first action that set's the angle to 0 may not be necessary, but it might give some more consistency to it.  Probably a better idea than setting the angle of the platform object would be to use a seperate object that you'd position to the other one, and then just change the angle of that.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)