Moving UP slopes in nehe's tutorial 11????
Hey guys, I''ve been making a basic ( for now ) game based around Nehe''s tutorial 11 and 23, and I''ve made some progress with it, but I''ve hit a stumping point.
In my game, I have made refined collision detection for EVERY direction, including up and down, and I have implemented gravity into the game ( in very basic form, just saying to push down unless its colliding. )
This means that now I can move around, and go DOWN slopes, but I don''t know how to make it go UP slopes using the basic map format used ( x,y,z,u,v )
Can anyone help? ( preferably with example code )
Thanx in advance for any help you guys can give me on this.
~Cobra~
P.S, I also have another game in the making, but I have this one firmly under control... I think you''ll like it. Nothing great, but it promises to be fun.
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
I haven''t looked over the nehe tutorial you used, but it seems like you could make the character/camera go up slopes by changing it''s position in a direction perpendicular to the normal of the surface that you''re on. For example, on flat ground, the normal is pointing straight up, so moving around on the flat ground, you would move straight left, right, forward, or backward. On a slope, the normal would be pointing off at an angle, so the paths perpendicular to it would also point off at angles.
Then when you come to a slope you want to go in, instead of moving your character and letting it fall down to the surface because of gravity, you would move it directly along the surface. There would be up and down components to the character''s displacement, that would occur outside of the collision detection and gravity scheme you''re talking about, so you could move up before getting stuck on the surface. Then once your character has moved, you apply the gravity and collision detection rules and voila, the character is higher than it was before.
I _think_ this would work, I''ve never actually tested it or anything myself. You could also set a maximum angle for the normal for this to work on so your character couldn''t go up steep slopes - for example, you could put in a line that said if(normalIsLessThan50DegreesFromVertical) moveInAnyDirection(); else onlyMoveDown(); or something to that effect.
Hope this helps!
/riley
Then when you come to a slope you want to go in, instead of moving your character and letting it fall down to the surface because of gravity, you would move it directly along the surface. There would be up and down components to the character''s displacement, that would occur outside of the collision detection and gravity scheme you''re talking about, so you could move up before getting stuck on the surface. Then once your character has moved, you apply the gravity and collision detection rules and voila, the character is higher than it was before.
I _think_ this would work, I''ve never actually tested it or anything myself. You could also set a maximum angle for the normal for this to work on so your character couldn''t go up steep slopes - for example, you could put in a line that said if(normalIsLessThan50DegreesFromVertical) moveInAnyDirection(); else onlyMoveDown(); or something to that effect.
Hope this helps!
/riley
--Riley
hehehe, that''s exactly how I thought of doing it!
But I''m not sure how to get the normal from the worlds used in those tutorials.
hmmmmmmmmmmmm.... can anyone help?
~Cobra~
But I''m not sure how to get the normal from the worlds used in those tutorials.
hmmmmmmmmmmmm.... can anyone help?
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Another way to do it would be to check to see if the character is within a small distance of the surface, but _under_ it. Then you could move your character, not worrying about collision detection quite yet, so your character would walk a little bit _into_ the slope. Then when you got to the collision detection bit it would have kind of a "pop up" effect. If you did it by very small increments it would probably seem like the character was going up the slope smoothly.
I think this might be what they do in Goldeneye for n64, because when you go on really steep hills you get a jerky up and down thing going.
I think this might be what they do in Goldeneye for n64, because when you go on really steep hills you get a jerky up and down thing going.
--Riley
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement