How to handle the effect of gravity during character jumping in side scrolling games

I’m making a side-scrolling game, and I’ve made a character controller based on a kinematic rigid body to use velocity (instead of force) to control my character. But I found some problems when writing the jumping code:

public virtual bool jump(float jumpSpeed)
{
	if (this.canJump() == false || m_kinematic.onGround == false) return false;

	m_kinematic.velocity += Vector2.up * jumpSpeed;

	return true;
}

Normally it will work fine, but if you jump while falling (such as during a double jump), the falling speed will cancel (or greatly weaken) the jumpSpeed, which is not good. Of course, I can simply:

m_kinematic.velocity = new Vector2(m_kinematic.velocity.x, jumpSpeed);

But what if I’m in an elevator that’s going up? That’s definitely going to be a problem. How do I deal with it? Or should I separate active speed (player key presses) from passive speed (environment imposed)?

I’m very inexperienced in game development, always stuck in various details, if you have any other suggestions, please let me know.(such as whether I should use velocity to control the character)
really looking forward to your answer:)

It seems like you are asking yourself all the right questions, but the answers are all very subjective. It all depends what kind of game you are making what you need to consider.

.

As you’re using a kinematic body for your character which means your velocity is unlikely to be affected by things like elevators unless you are manually putting in code to make the player move up while stood on an elevator. In which case it should be fine to override that velocity on jump, or just add the current velocity of the elevator to your jump velocity when you jump.

.

Another thing you might consider is that a lot of games change the gravity scale while you jump to lower it until you release the button/start falling. This might also help you with your problem. I’d guess that most snappy platformers are probably also resetting the vertical velocity whenever you jump though.