Posted By
|
Message
|
J.C
Registered 22/03/2013 05:18:14
Points 118
|
10th May, 2014 at 10/05/2014 20:35:09 -
Has anyone tried to pull off a swimming mechanic in their games?
I'm trying to make it so that a character can swim while overlapping a water backdrop.
n/a
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
10th May, 2014 at 10/05/2014 21:49:45 -
Well if you want like a Mario type swim just lower gravity and allow the user to jump regardless of whether they're touching the ground. That should do it assuming you have a decent platforming engine.
For switching between modes it might be easier to make the water level the same through out the level and then just check if the player is below the water level with:
IF player Y position is < 400 then
-Set swimmode = 1
IF player Y position is > 400 then
-Set swimmode = 0
n/a
|
AndyUK Mascot Maniac
Registered 01/08/2002
Points 14586
|
10th May, 2014 at 10/05/2014 23:57:33 -
In the past ive made two completely separate player movements for in water and out of water, but that's too much work really.
What you need as UrbanMonk is suggesting is a way to just alter your player's movement. So in water the player will move slower, slow down faster, jump lower etc.
.
|
J.C
Registered 22/03/2013 05:18:14
Points 118
|
11th May, 2014 at 11/05/2014 01:14:17 -
Hmm...good suggestions. But what if the level has bodies of water that vary in water levels?
And as usual, if you can provide an example of the code, or if you can create an example file, I would very much appreciate it.
n/a
|
AndyUK Mascot Maniac
Registered 01/08/2002
Points 14586
|
11th May, 2014 at 11/05/2014 18:21:38 -
Just make the water backdrop an active object and check if the player is overlapping one. They don't have to be huge, they can be 8x8 and then resized in one of your events.
Edited by AndyUK
.
|
The_Antisony At least I'm not Circy
Registered 01/07/2002
Points 1341
|
13th May, 2014 at 13/05/2014 04:29:20 -
You could also use four small 8x8 detector objects.
Object1: Start of global water level.
Object2: End of global water level.
Object3: Start of variable water level.
Object4: End of variable water level.
Then just test the player object for when it is between the X of Object1 and Object2+width(Object2) and also has a Y of more than the Y of Object1.
Do the same for Object3 and Object4 respectfully. Object 3 and 4 can appear above the level's global water level and still initiate a change in movement or lower gravity and a multijump.
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
13th May, 2014 at 13/05/2014 04:48:11 -
Basically you just need a way to detect when the player enters a water-area and when they leave and work from there.
You could do that with an invisible active that covers the tops of each body of water then use the following code to set the flag for changing the movement type:
If "player" is overlapping "water-detector" and
If "player" Y position < "water-detector" Y position
-Set swimmode = 1
If "player" is overlapping "water-detector" and
If "player" Y position > "water-detector" Y position
-Set swimmode = 0
And that should cover it for changing the players movement when they enter a water area. This water-detector object would just be an active that is a thin horizontal line that sits at the surface of each water area. From there it's pretty easy to add new water areas.
That should fix your issue with bodies of water at different water levels.
EDIT: As a side-effect of using this method you can easily tack on water splashes when the player enters and exits the water. Boom!
Edited by UrbanMonk
n/a
|
J.C
Registered 22/03/2013 05:18:14
Points 118
|
23rd May, 2014 at 23/05/2014 03:10:45 -
Originally Posted by -UrbanMonk- Basically you just need a way to detect when the player enters a water-area and when they leave and work from there.
You could do that with an invisible active that covers the tops of each body of water then use the following code to set the flag for changing the movement type:
If "player" is overlapping "water-detector" and
If "player" Y position < "water-detector" Y position
-Set swimmode = 1
If "player" is overlapping "water-detector" and
If "player" Y position > "water-detector" Y position
-Set swimmode = 0
And that should cover it for changing the players movement when they enter a water area. This water-detector object would just be an active that is a thin horizontal line that sits at the surface of each water area. From there it's pretty easy to add new water areas.
That should fix your issue with bodies of water at different water levels.
EDIT: As a side-effect of using this method you can easily tack on water splashes when the player enters and exits the water. Boom!
I just tried that, but I can't seem to get the variables right (I'm using the PMO object for my player character). Changing the maximum/additional Y velocity ends up preventing the player from jumping.
n/a
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
25th May, 2014 at 25/05/2014 22:26:50 -
I don't use the PMO so I can't help you there, so for the actual movement modifications you'll need to ask someone who knows how to use that object.
n/a
|
J.C
Registered 22/03/2013 05:18:14
Points 118
|
26th May, 2014 at 26/05/2014 17:08:10 -
Originally Posted by -UrbanMonk- I don't use the PMO so I can't help you there, so for the actual movement modifications you'll need to ask someone who knows how to use that object.
So PMO is out of the question here. Okay then, what variables do you alter when you have the player character go underwater? Gravity? Y/X Velocity?
n/a
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
26th May, 2014 at 26/05/2014 19:31:37 -
Experiment. It seems like decreasing gravity would do it, but if that isn't working for you try something else. Trial and error.
n/a
|
vSv
Registered 06/04/2010
Points 373
|
27th May, 2014 at 27/05/2014 21:38:11 -
Originally Posted by J.C
Originally Posted by -UrbanMonk- I don't use the PMO so I can't help you there, so for the actual movement modifications you'll need to ask someone who knows how to use that object.
So PMO is out of the question here. Okay then, what variables do you alter when you have the player character go underwater? Gravity? Y/X Velocity?
Hi!
I have some experience using the PMO and water. The same principle for creating water can also be used to create quicksand and similar things.
What I did was this:
1. Create a group of events called "Land/Water", another group of events called "Land" and one last group of events called "Water".
(It doesn't matter what you call them as long as you can keep track on them yourself.)
2. In the group "Land/Water" create an "Always" event, then set ALL your desired basic preferences of the PMO such as the "Max X Velocity", "X Velocity" and "GetJumpStrength".
(You can also create global values on the PMO and then set these basic preferences to these global values, then rename them to the same thing as the PMO's values, I use these global values for calculating my movements. If you don't feel the need for this you can probably skip setting them as global values.)
3. In the group "Land/Water" create an event for when "Group Land is activated" and then change your desired non-water preferences on the PMO like "Jump Strength" and "Max Y Velocity" to whatever you want it to be.
4. In the group "Land/Water" create an event for when "Group Water is activated" and then change your desired water preferences like "Gravity" to whatever you want it to be.
5. In the group "Land/Water" create the event "Only one action when event loops" + " 'Player Collider' is overlapping 'Group.0' ". When this event occurs "Activate group Water" and "Deactivate group Land".
(In my case the "Player Collider" is the hitbox for my character and "Group.0" is just a qualifier that I put on an invisible active object which will serve as the water when the player overlaps it.)
6. In the group "Land/Water" create the event "Only one action when event loops" + " 'Player Collider' is not overlapping 'Group.0' ". When this event occurs "Activate group Land" and "Deactivate group Water".
7. You can also put all your stop in movement events, common animations and other things that should be universal for both the Water and Land movement in the group "Land/Water".
8. Then finally just put all your desired non-water movement events in the "Land" group and all the water movement events in the "Water" group.
(For example, my movements Slope-Sliding is in the "Land" group as I don't want the player to be able to "Slope-Slide" under water.
I hope this helps. Although I'm very tired now and might have missed some things. Just tell me if it didn't work and I'll create an example file for you instead.
- vSv
|
J.C
Registered 22/03/2013 05:18:14
Points 118
|
29th May, 2014 at 29/05/2014 03:29:24 -
Hi!
I have some experience using the PMO and water. The same principle for creating water can also be used to create quicksand and similar things.
What I did was this:
1. Create a group of events called "Land/Water", another group of events called "Land" and one last group of events called "Water".
(It doesn't matter what you call them as long as you can keep track on them yourself.)
2. In the group "Land/Water" create an "Always" event, then set ALL your desired basic preferences of the PMO such as the "Max X Velocity", "X Velocity" and "GetJumpStrength".
(You can also create global values on the PMO and then set these basic preferences to these global values, then rename them to the same thing as the PMO's values, I use these global values for calculating my movements. If you don't feel the need for this you can probably skip setting them as global values.)
3. In the group "Land/Water" create an event for when "Group Land is activated" and then change your desired non-water preferences on the PMO like "Jump Strength" and "Max Y Velocity" to whatever you want it to be.
4. In the group "Land/Water" create an event for when "Group Water is activated" and then change your desired water preferences like "Gravity" to whatever you want it to be.
5. In the group "Land/Water" create the event "Only one action when event loops" + " 'Player Collider' is overlapping 'Group.0' ". When this event occurs "Activate group Water" and "Deactivate group Land".
(In my case the "Player Collider" is the hitbox for my character and "Group.0" is just a qualifier that I put on an invisible active object which will serve as the water when the player overlaps it.)
6. In the group "Land/Water" create the event "Only one action when event loops" + " 'Player Collider' is not overlapping 'Group.0' ". When this event occurs "Activate group Land" and "Deactivate group Water".
7. You can also put all your stop in movement events, common animations and other things that should be universal for both the Water and Land movement in the group "Land/Water".
8. Then finally just put all your desired non-water movement events in the "Land" group and all the water movement events in the "Water" group.
(For example, my movements Slope-Sliding is in the "Land" group as I don't want the player to be able to "Slope-Slide" under water.
I hope this helps. Although I'm very tired now and might have missed some things. Just tell me if it didn't work and I'll create an example file for you instead.
Thanks vSv! I will try to incorporate this code into my game. Though an example file would be great if you could kindly provide one.
n/a
|
vSv
Registered 06/04/2010
Points 373
|
29th May, 2014 at 29/05/2014 09:40:20 -
Hi again!
I made an example file for you!
Although, you might have to customize it a little bit to better suit your game!
http://www.mediafire.com/download/8id51ofd3qu7tjj/Water_Land.mfa
- vSv
|
J.C
Registered 22/03/2013 05:18:14
Points 118
|
30th May, 2014 at 30/05/2014 04:55:35 -
Originally Posted by vSvHi again!
I made an example file for you!
Although, you might have to customize it a little bit to better suit your game!
http://www.mediafire.com/download/8id51ofd3qu7tjj/Water_Land.mfa
I tried to open the file, but as MMF opened it said Unknown Format, Failed to Open file. You're using CTF, I am using MMF2.
n/a
|
|
|