PLATFORMER:Change behavour when overlap to Swim

Get help using Construct 2

Post » Tue Oct 25, 2011 3:12 pm


EDIT: Well I was playing today with this challenge and came up with a solution thanks to few comments to give me the right idea.
So heres one solution i came up with

Example contains:
-Basic description in eventsheet
-Combination of two player sprites with platform and 8dirrection behavour
-Immitation of swimming with jumping out effect
-Very basic animation sprite effected by player movement

File: http://dl.dropbox.com/u/5214903/GM/SwimmBehavour.zip



----------------------------------------------------------------------

Hello

What Id like to do is a platform game where by overlaping the water area, the players "Platform" behavour would change into "8direction" behavour to imitate swimming.
The way I understanded it, is the Ignore input suposed to be used for what I plan.

Problem:
-Platform behavour wont jump
-When overlaping the water area, player does change into 8 dirrection but sinks to the botom


Illustrated Plan:



File:
http://dl.dropbox.com/u/5214903/GM/LetsGoSWIMM/letsGoSwimm.zipMiu32011-11-01 11:08:45
B
43
S
9
G
5
Posts: 231
Reputation: 7,291

Post » Tue Oct 25, 2011 3:31 pm

I have the same question actually, is behavior changing on runtime planned?
B
106
S
35
G
37
Posts: 798
Reputation: 25,215

Post » Tue Oct 25, 2011 6:19 pm

It isn't possible to change behaviors like that right now, but there's some workarounds to accomplish the same effect. One thing you can do is to not use the 8 directional movement at all, but to recreate that movement USING the platform behavior; set gravity to 0 so your character won't fall, and then have swimming-specific events that make you move in every direction upon key presses as if you were using 8direction.

Another thing you can do is make the player invisible and spawn a new player, one that looks like the same but uses 8direction instead of platform. Then when you jump out of the water, destroy the water-player and make the normal platform player visible again.

Neither one is ideal, but there may not be any other way to get it done. If you're still not clear on how to do it I could try to make an example for you. Hope this helps!
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Tue Oct 25, 2011 6:34 pm

http://dl.dropbox.com/u/3232744/swim/index.html
http://dl.dropbox.com/u/3232744/swim/swim.capxKastas2011-10-25 18:36:39
B
79
S
32
G
23
Posts: 119
Reputation: 14,937

Post » Wed Oct 26, 2011 5:25 pm

Thankyou very much for this example!

It is definitely also a good way to create swimming behavour, allthough I noticed a glitch where the playier jumps out and remains in swimming mode while in air...

The reason why I want to change the player from platform to 8 direction mode is to get more control in movement and not be influenced by things like gravity.
B
43
S
9
G
5
Posts: 231
Reputation: 7,291

Post » Wed Oct 26, 2011 5:29 pm

These are definitely good ideas to make what I have in mind.
Ill definitely gonna try and examples would definitely be moust apreseated :)


Thankyou
B
43
S
9
G
5
Posts: 231
Reputation: 7,291

Post » Tue Nov 01, 2011 11:13 am

Made a new edit of this topic with new working example
B
43
S
9
G
5
Posts: 231
Reputation: 7,291

Post » Tue Nov 01, 2011 11:48 am

Thanks @Miu3, it will help and is really appreciate.

What about a "jumping to dive" pose right before reach the water? I'll figure it out today, maybe using transparent objects to detect the water before he reach it.

Thanks @Kastas, your sample really help ^^

While Diablo 3 don't come, let's make games xD
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,211
Reputation: 18,480

Post » Wed Aug 22, 2012 3:11 pm

That's the only feature missing in my platform game.
B
85
S
31
G
22
Posts: 384
Reputation: 18,592

Post » Fri May 17, 2013 10:42 am

This is a pretty old topic, but it's on the FAQ page and States are important, so...

I make a Multi-State object by giving the object an Instance Variable which I call "State", which I set to a String. Make the default something like 'Walk' or 'Move'
For your purposes, add both Platform and 8-Direction, but disable the 8-Direction to start.

On the event sheet where you handle controlling your player, begin with the event "Compare Instance Variable" and see if it reads "Walk" Put all walking, running, standing on ground behaviors there. For your purposes, there you would use 'Set Enabled' to Enable Platform and Disable 8-Direction

Next, when your player makes contact with the water, set 'State' to "Swim" and set it back to "Walk" when the player is not in contact with water (I think the 'Overlap' function would work there)

Then, same thing, do a 'Compare Instance Variable' to see if State is "Swim", disable Platform and enable 8-Direction, then put in all your Swimming Behavior (such as changing animations to swimming, any swim-specific controls, even adding an Air Meter to the HUD if you'd like)

It may seem a bit complicated, but that system (based off a Finite State Machine, if you want to look that up) is extremely powerful and makes for fairly clean code once you get used to it. You can use that same 'State' variable for climbing ladders, flinching on taking damage, and anything else that temporarily changes the behavior of your character.

Hope that helps somebody!
B
7
S
2
G
1
Posts: 4
Reputation: 997

Next

Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, MrWhizm, Skebab, spcsmrf and 21 guests