Player to swim

Get help using Construct 2

Post » Thu Mar 07, 2013 9:24 pm

How do I get the player to swim?
Ability to jump in water, but not in mid air.
B
10
S
3
Posts: 86
Reputation: 1,508

Post » Thu Mar 07, 2013 10:52 pm

iF keyIsDown == jumpButton
   IF player object and water object are overlapping
   THEN playerY+=1 (or you could simulate jump control on the player platform behavior)
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Fri Mar 08, 2013 12:37 am

Thanks, but I don't quite understand yet.

Add event: -- Add Action?
Add sub events: ?
B
10
S
3
Posts: 86
Reputation: 1,508

Post » Fri Mar 08, 2013 1:07 am

ensure you you a keyboard object in your project.

add event: Keyboard>KeyIsPressed>Space (or whatever you use for jump)
add condition: Player>IsOverlappingOtherObject>Water
add action: Player>Platform.VectorY = Player.Platform.VectorY + swimUpVector

where swimUpVector is the amount of upward velocity per tick that should be added to the player. try 250 or so and work from there.
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Fri Mar 08, 2013 5:58 am

I tried adding "swimUpVector" to the player's variables
then I added it to action: "Set Vector Y"
and to that I put in: Player.Platform.VectorY + swimUpVector

but then it told me that "swimUpVector" is still an unknown variable.
B
10
S
3
Posts: 86
Reputation: 1,508

Post » Fri Mar 08, 2013 10:10 am

swimUpVector is not a variable you make in construct its a number you set based on how high you want the jump to be, if you want the player to go higher set it to like 500, that will be a normal jump (i think 650 is default jump height in construct 2 platform behavior.)

so it should look like

add event: Keyboard>KeyIsPressed>Space (or whatever you use for jump)
add condition: Player>IsOverlappingOtherObject>Water
add action: Player>Platform.VectorY = Player.Platform.VectorY + 250BACLog2013-03-08 10:11:56
B
22
S
5
G
1
Posts: 81
Reputation: 2,271

Post » Fri Mar 08, 2013 6:47 pm

I'll give this a try.
===
This doesn't seem to be working, as I might be missing something still.
B
10
S
3
Posts: 86
Reputation: 1,508

Post » Fri Mar 08, 2013 8:55 pm

or if you've added swimUpVector to the player's variables, then it will be player.swimUpVector.
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Fri Mar 08, 2013 8:57 pm

Upload your capx if you are still having problems. (please don't be beta, please don't be beta)
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Fri Mar 08, 2013 9:38 pm

Yes, that is a lot better.   It finally worked.
Thank you for your help. He can swim now.
B
10
S
3
Posts: 86
Reputation: 1,508

Next

Return to How do I....?

Who is online

Users browsing this forum: makkancs and 26 guests