enemy behavior - crawl around platforms [SOLVED]

For questions about using Classic.

Post » Wed Jun 13, 2012 1:13 am

I've been struggling with this enemy behavior for hours now and can't seem to come up with a decent solution. The game is a platformer, BTW. What I'm looking to do seems simple enough and is illustrated by this image. I just want the enemy to follow along the edge of a tiled background objects.



Think of those little spiny enemies in Metroid that can crawl around a platform.



I've been using a lot of "overlap at offset" events to set the enemy's speed and direction but I keep ending up with the object floating into space or moving through the background. The only solution I can come up with is to place a series of sprites at the corners that act as sensors, but it's not a very elegant solution. If anyone has an idea on how to make this work, I'd really appreciate it. robit_studios2012-06-14 01:55:36
B
20
S
5
G
3
Posts: 65
Reputation: 3,764

Post » Wed Jun 13, 2012 2:28 pm

Maybe attach invisible detector sprites to each of the four sides of the sprite using image points. Then check which detector sprites overlap a tiled background to find where to go.

I can give this a try later this week if you'd like an example.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed Jun 13, 2012 7:39 pm

@robit_studios
Hi this may help you...

Stick to Plattaform

The key is where to put the gravchangers... and you may use the dummyplayer to attach your real player or enemy sprite...

there is another method if you dont like active one...

PD: sorry my english...

^_^Yaottabyte2012-06-13 20:17:47
B
4
S
1
G
1
Posts: 69
Reputation: 863

Post » Wed Jun 13, 2012 8:53 pm

@JayJay - I've considered this idea but I don't think it'd give me much more of an advantage over just using "overlap at offset" events. Maybe I'm wrong though?

@Yaottabyte - Thanks for taking the time to make that example. This is actually similar to how I have the enemy setup currently. It definitely works but I was hoping to find a method to avoid having to put a bunch of sensors on the corners of all the platforms.

Ok, I put together an example CAP. If you try this you'll see that it works SOMETIMES.. but other times the enemy just randomly flys off the screen. It uses "overlap at offet" and "overlap at point" to detect the edges.

https://dl.dropbox.com/u/28484936/crawling_enemy.cap

Edit: Ok, after toying around with FPS settings I see now that the problem has everything to do with how fast the enemy is going. If I set the enemy speed to 80 - no problems. If I set it to 120 if will occasionally fly away. If I turn off v-sync and pump up the FPS to 200 I can make the enemy move very fast with no problems. Since I can't expect the game to run at 200 FPS I still need to come up with a solution for this.robit_studios2012-06-13 21:31:51
B
20
S
5
G
3
Posts: 65
Reputation: 3,764

Post » Wed Jun 13, 2012 9:19 pm

Could you do something simple like have the enemy always have a movement component toward the center of the platform and then a separate movement component perpendicular to that? The math might be a bit unintuitive if you want to get consistent movement speed along the edge of the platform, but should be simple enough. I think there's Actions in the Custom Movement behavior that will allow you to turn an enemy to face toward an object all the time, etc.

Alternatively, maybe you can use the platformer behavior to set gravity direction be toward the center of the platform, which is the same as above but might save you some time doing calculations.

I can try to put it together later today when I get home, since it seems like a fun problem to solve.

Also, check out this plugin, maybe it can do what you want:

http://www.scirra.com/forum/path-movement-behavior_topic39306.htmlJuryiel2012-06-13 21:24:33
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Wed Jun 13, 2012 9:20 pm

And like that?

edit: ops, didn't read Juryiel's post entirely^^. Well, now you even have an example .cap of his suggestion.zyblade2012-06-13 21:33:16
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Wed Jun 13, 2012 9:41 pm

@zyblade Thanks for the example. I considered the path movement option, but it won't work for my purposes. I don't want the enemies to have a fixed path. I want the enemies to be able to thrown off of their platform and attach themselves to wherever they land and continue moving.
B
20
S
5
G
3
Posts: 65
Reputation: 3,764

Post » Wed Jun 13, 2012 10:13 pm

@zyblade, @robit_studios is right i'd tryed path behavior too but with odd results, i'll try something at home this night(Venezuela hehe) well tomorrow i'll post results...

EDIT: almost i forgot, @robit_studios try in my example, there is a method inside a disabled group thats quite different to sensor method, i'll change methods in my above post check it again!.

EDIT 2: ready try again my example was updated, ignore gravChangers they are there because old method, now using a new method try to play with plattaforms to get desired results...Yaottabyte2012-06-13 22:21:30
B
4
S
1
G
1
Posts: 69
Reputation: 863

Post » Wed Jun 13, 2012 10:30 pm

@Yaottabyte I really like your method of changing the direction of gravity but I've run into one problem. I'm using Tiled Background objects for my platforms and there doesn't seem to be a way to "Pick closest to" for Tile Background objects.
B
20
S
5
G
3
Posts: 65
Reputation: 3,764

Post » Wed Jun 13, 2012 10:32 pm

no matters just use my dummy plattaforms and overlaps yours TB then make them invisible at start... they works as references...

EDIT: added some tiledBackgrounds to show how use the method with yours...
EDIT 2: a last tip, to my plattaforms dummies uncheck the plattaform attribute, and check it to your TiledBackgrounds so enemies move over your TBs and use the dummies as references to change gravity...Yaottabyte2012-06-13 22:40:04
B
4
S
1
G
1
Posts: 69
Reputation: 863

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests