What is AX and AY (as opposed to ax and ay), and where are they being set?
FWIW, I think you should take a generic approach to this, and it should not be player specific as well as a change to how you handle collisions. What I mean is:
#1, These functions need to be defined in some movable class that handles movement for everything that can move (players, enemies, other objects)
#2, Gravity should be added to an objects y-velocity every frame. This means you'll also have to compute if an object is on the ground every frame too, and reset the y-velocity to 0. This will make handling jumping and walking off platforms a breeze.
#3, Move the object in 1 axis only, then check collisions, then move in the other axis. Imagine a player moving right and jumping into a wall. It will collide with the wall, but do you want to stop the upwards (and downwards) motion of the player when it hits the wall? No, so, move in the X-axis, check collisions, and reset X-position if collided, then move in y-axis and check collision and reset y-axis if colliding. This will handle all sorts of collisions (hitting your head while jumping to the right for example).
Good luck and have fun.
AX and AY are the just properties for aX and aY, they basically act as getters and setters for the variables. aX and aY are being set in the main game loop where it just takes the direction of the thumbstick and adds to the variable depending on how much it's pressed.
1. I agree with you, I'll change that after I get it working correctly. This is just a prototype I was throwing together because I've never worked in monogame or C# before(I come from a Java and LibGDX background)
2. That was originally what I had done, but I changed it to what I have now because I was getting some stuttering when the block was on the ground. It would accelerate too quickly into the ground and a collision would occur to move the object back above the ground.
3. That makes a lot of sense, I'll give that one a shot.
Video looks okay, so itmust just "feel" wrong.
If you are setting ax instead of vx it is going to feel slow and delayed. Playformers normally let you instantaneously change direction, which means setting vx, at least when airborne.
On the ground you might want to set ax to give the character momentum. Adding an animation will help it feel less delayed, as something will happen i.mediately when you try to change direction.. Try changing the block to an arrow in the direction of ax. Perception matters.
Oh okay, I see what you mean. That had never occurred to me, I'll try implementing changing the velocity directly as opposed to the acceleration.
I'll look into adding an animation for the play and see what happens. I've never done anything like that with monogame so that means there's some more reading to be done
If the height of the intersection is larger than the width (as might be when you are on the edge of a platform), then it doesn't bother with checking to see if you landed on something. Seems flawed.
It is more common to check one direction, correct for interpenetration, then re-calculate intersection for the other direction.
I found that in a thread a while ago(I don't remember where exactly) where it was suggested to check which collision axis was shallower to determine which collision has happened first. I have changed that already but I did so before seeing your post.
What I've done is get two time variables that are basically float timeY = intersection.Height/velocityY and the same for X. This has been a lot more accurate.
My problem I'm having now is that the movement feels VERY unnatural. But I suppose that is just a matter of tweaking values, right? I was also considering changing all my movement related variables from ints to floats to get slightly more smooth movements. Would this help?
I'm not at my PC at the moment but all the code for jumping does is increase the y velocity by a set amount. I can post a video of the behavior in the morning since I'm a little unsure how to explain it