Collision problems

Blitz3D Forums/Blitz3D Beginners Area/Collision problems

fox95871(Posted 2009) [#1]
All I want to do is run and jump in a 3d level, why is that so difficult? I know, I know, it can be done. Well, here's my 10% working code for anyone who wants to try to help:



Currently gravity is off, and jumping is nonexistent. I want to fix the more basic problems first. If anyone's looking for something to do, I'd really appreciate the help. I've been avoiding collisions long enough.


Warner(Posted 2009) [#2]
Here is something I tried, hopefully it is helpful:



fox95871(Posted 2009) [#3]
Hope so! Thanks, I'll try it tonight.


fox95871(Posted 2009) [#4]
Thanks! I'm really happy with this.

I want to alter it a bit, but I think I can handle doing it myself. I want to: remove all control after a jump has been started so you can't move in midair, make jump KeyHit instead of KeyDown so you don't accidentally bounce, and I need to freeze the camera again because my game's going to use all 2d overlays for the level graphics. I also need to see if my facing code will work with what you did. Did you remove it because it didn't?


Kryzon(Posted 2009) [#5]
Wouldn't those extra UpdateWorld calls screw up animations? everytime you call TestPosition, all the animations in your game would be updated.
I think you need to send (0) to it just so it doesn't update the animations.


Warner(Posted 2009) [#6]
That is indeed a good suggestion: to use "UpdateWorld 0" instead. Also, if no keys are pressed, TestPosition (and Move) should not be used. The way it works now it is calling UpdateWorld too often.
The reason I removed the facing code is that I figured it would be more easy to use a sphere as a character, since all collisions are sphere-to-something else. So by using a sphere, you can see what the collisions are doing. When the sphere is working, it can be replaced by something else.


fox95871(Posted 2009) [#7]
I noticed one thing that would be a pretty big problem for me. If you go to the top of the hill and then try to walk down it to the right and jump to the ledge from about the middle of the slope, it's pretty much impossible because you're usually in the air. My game's going to have lots of places where you have to jump from slopes to other things. Is there a way this pseudocode could be written in Blitz?

Character is always attached to the ground unless jump is pressed
If jump is pressed, character detaches from the ground with a set y speed
Gravity subtracts from the y speed until the character is attached to the ground again


fox95871(Posted 2009) [#8]
I couldn't get my facing code to work with it afterall. I think I'm just going to copy every single example of this kind of code on the site til I find one that works. The tediousness of that seems less likely to make me lose it.

If anyone knows of any threads with complete examples of running and jumping in a 3d area please point them out to me. Til then I'll just keep searching.


fox95871(Posted 2009) [#9]
This topic is continued at http://www.blitzbasic.com/Community/posts.php?topic=84846