#Mario-like swimming help, ad general control issues

1 messages · Page 1 of 1 (latest)

lone mango
#

Hello!

I'm working on a Mario-like platformer on my end. I noticed that my controls for swimming and going up and down slopes are weird. First I slide down slopes instead of sticking to them.

https://pastecode.io/s/wp03ace9

Then I pretty much have to start over because while I can manage the basics of Mario-like swimming, I can't get the more complicated details right. The player leaves water too easily and if you were on ground, you swim up too high.

https://pastecode.io/s/cxnakaz0

It's kind of a mess, and I don't know when to start.

untold kestrel
#

What is the relationship between the 2 scripts? Are you disabling/enabling them when being on a slope/in water? That's feels like a very fragile setup.

lone mango
#

Yeah... Like I said, I'm kind of a beginner. I tought it was a good idea to split movement, slope handling and movement, and swimming, into separate scripts...

untold kestrel
#

Instead of having separate states for each environment, you should think of what differentiates them. For example, the gravity value could be different in water and ground, or an additional force(buoyancy force) should be applied. Then there's the differences in friction. You could only manipulate these parameters to make the difference and add some small specific flags, like "can move vertically" or something, and have it all in one script. This way you can focus on controlling the actual behavior rather than troubleshooting each state and transitions between them individually.

lone mango
#

so I should mix them into one giant script? i'm still a little lost...

untold kestrel
#

Not giant. There's no need for it to be giant. And there are better ways to split code into logical parts.

Point is, have one logic for all the cases, but separate data/parameters for them, instead of having separate logic.

lone mango
#

okay.... honesly, as a newb who sticks to small scripts, I'm scared I don't even know where or how to start,

untold kestrel
#

Well, define how you want your system to work first.
Write it down on paper.
Then think of the different environments, like underwater or in the air, and write down their differences.

lone mango
#

ok, i'll try.

lone mango
#

I'll try to take notes on how to detect swimming and being in a slope or quicksand, and changing the player's behavior accordingly

#

man i bit off more than icould chew

lone mango
#

So, the Mario-like swimming seems to be working. But the slopes, though? that's another story. i slip and bounce from them, i don't move in parallel from them.

https://pastebin.com/r6JWKPSr

#

the material also refuses to change for the player, too.

#

so clearly there's a problem in how my player object detects slopes. i just can't see it

lone mango
#

I also tried to follow a tutorial online: https://www.youtube.com/watch?v=QPiZSTEuZnw

#

The catch is that I don't cling or detect slopes as I should

lone mango
#

I cling on slopes a little better! But now I slowly gop down them if I'm still, and still tend to slide off of them sometimes...

#

I think gravity is messing with my game plan here

lone mango
#

Only issues left are:
I can't go up a 45 degree slope from a flat surface at the bottom.
I can't descend from a 45 degree slope because I might slip and slide off.

I made the gravity not affect the player when they're still on slopes, but it's a quickfix at best.