- #1
cubby208
- 6
- 0
So, I was working on some code to handle this.
Basically the setup is I have x, y, and z velocity. So if x is negative then move left. If y is positive move up. Z is positive move forward etc.
When keys are pressed I add (or subtract) to the proper velocity value. Their are two parts of this code I just can't wrap my head around. One is that when the player is on the ground I want movement to feel like it is not a velocity based platformer. Feeling close to walking, however as soon as the player jumps I want it to be different. I want the jump to have direction to it based on the players velocity. In short emulating reality fairly closely. Second is gravity. I don't understand it! Ill summarize below what I don't get.
It is a basic 3d platformer, and only one object will be moving so no need to worry about mass. Also their are no slopes.
Anyway here are my main questions.
Basically the setup is I have x, y, and z velocity. So if x is negative then move left. If y is positive move up. Z is positive move forward etc.
When keys are pressed I add (or subtract) to the proper velocity value. Their are two parts of this code I just can't wrap my head around. One is that when the player is on the ground I want movement to feel like it is not a velocity based platformer. Feeling close to walking, however as soon as the player jumps I want it to be different. I want the jump to have direction to it based on the players velocity. In short emulating reality fairly closely. Second is gravity. I don't understand it! Ill summarize below what I don't get.
It is a basic 3d platformer, and only one object will be moving so no need to worry about mass. Also their are no slopes.
Anyway here are my main questions.
- How should I process drag both on the ground and in the air to simulate reality?
- How do I apply gravity? About what number should I use? Do I need to account for "terminal velocity? If I am falling do I constantly subtract gravity from the y velocity?
- When the player runs into a wall (not floor or ceiling) what should happen to the velocity? No need to account for restitution, and probably not friction.
- What should happen to the velocity when the player hits a ceiling?