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

Get help using Construct 2

Post » Sun Aug 16, 2015 11:19 pm

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
B
14
S
2
Posts: 73
Reputation: 794

Post » Mon Aug 17, 2015 12:20 am

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.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Mon Aug 17, 2015 2:48 am

R0J0hound wrote: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.
B
14
S
2
Posts: 73
Reputation: 794

Post » Mon Aug 17, 2015 4:13 am

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.
Code: Select all
+------------------------+
|                        | 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
      +------------------+


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.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779


Return to How do I....?

Who is online

Users browsing this forum: dop2000, R0J0hound, tarek2 and 27 guests