How do I jump up a wall onto platfrom

Blitz3D Forums/Blitz3D Programming/How do I jump up a wall onto platfrom

Rob Pearmain(Posted 2003) [#1]
Here is what I mean



The problem with Blitz collision is that if you are moving forward and up and hit a wall you "stick" or "slide". What I want to do is when my player jumps, if there is a wall infront of him, move up, and only when the collision in front of him is no longer there carry on moving forward, like on manic Miner but in 3d.

In figure 1, this is how he jumps when no platform is there
In figure 2, this is how blitz collision works, it stops the player
Figure 3 is how i would like it to work


BlitzSupport(Posted 2003) [#2]
Crude, and just thinking aloud from looking at the diagrams: have a pivot just in front of your character, then once the pivot collides with the block, delete it [maybe disable character collision here], move the character up until you're a bit above the topmost y position of the block, move forward/arc as appropriate [re-enable character collision if disabled] and recreate the "there's-a-block-in-front" pivot...?


Rob Pearmain(Posted 2003) [#3]
Yes, that would work. After further reading, what about linepick, could that be used?


GfK(Posted 2003) [#4]
You could use Linepick, but A) Its not that fast (you'd get away with a few linepicks per frame@60fps though) and B) Your entire game map would have to be pickable (polygon mode) in order for linepick to work.


darklordz(Posted 2003) [#5]
Why not make a mini elevator (I know i didn't help....)


Rob Farley(Posted 2003) [#6]
Um... Isn't that how the collision works already?

left/right arrows to move, left ctrl to jump.

Graphics3D 640,480


SetBuffer BackBuffer()

Collisions 1,2,2,2

player=CreateSphere()
EntityType player,1

wall=CreateCube()
EntityType wall,2

wall2=CreateCube()
EntityType wall2,2

ground=CreateCube()
ScaleEntity ground,20,.1,4
EntityColor ground,0,150,0
PositionEntity ground,0,-1,0


PositionEntity player,-10,0,0
PositionEntity wall,5,1,0
ScaleEntity wall,.5,2.5,2
EntityColor wall,100,0,0
PositionEntity wall2,10,3,0
ScaleEntity wall2,5,.5,2
EntityColor wall2,100,0,0

camera=CreateCamera()
PositionEntity camera,0,10,-20
TurnEntity camera,10,0,0

light=CreateLight(2)
PositionEntity light,100,100,-20

movepivot=CreatePivot()

Repeat


If KeyDown(205) Then TranslateEntity movepivot,.05,0,0
If KeyDown(203) Then TranslateEntity movepivot,-.05,0,0
If KeyHit(29) Then TranslateEntity movepivot,0,1.5,0

TranslateEntity movepivot,0,-.05,0
TranslateEntity movepivot,-EntityX(movepivot)*.1,-EntityY(movepivot)*.1,-EntityZ(movepivot)*.1

MoveEntity player,EntityX(movepivot),EntityY(movepivot),EntityZ(movepivot)
If EntityY(player)<0
	PositionEntity player,EntityX(player),0,EntityZ(player)
	TranslateEntity movepivot,0,EntityY(movepivot)*-2,0
	EndIf



UpdateWorld
RenderWorld
Flip
Until KeyHit(1)



Rob Pearmain(Posted 2003) [#7]
Excellent stuff Dr Av ;-) !

I have amended your code so that keypresses are ignored when mid air by checking collisions on the player to ensure there is no CollisonsNY

Graphics3D 320,240

SetBuffer BackBuffer()

Collisions 1,2,2,2

player=CreateSphere()
EntityType player,1

wall=CreateCube()
EntityType wall,2

wall2=CreateCube()
EntityType wall2,2

ground=CreateCube()
ScaleEntity ground,20,.1,4
EntityColor ground,0,150,0
PositionEntity ground,0,-1,0



PositionEntity player,-10,0,0
PositionEntity wall,5,1,0
ScaleEntity wall,.5,2.5,2
EntityColor wall,100,0,0
PositionEntity wall2,10,3,0
ScaleEntity wall2,5,.5,2
EntityColor wall2,100,0,0

camera=CreateCamera()
PositionEntity camera,0,10,-20
TurnEntity camera,10,0,0

light=CreateLight(2)
PositionEntity light,100,100,-20

movepivot=CreatePivot()

moveman#=0

Repeat


if ycollided
moveman=0
If KeyDown(205) Then moveman = .05
If KeyDown(203) Then moveman = -.05
end if
translateentity movepivot,moveman,0,0

ycollided = 0


TranslateEntity movepivot,0,-.05,0
TranslateEntity movepivot,-EntityX(movepivot)*.1,-EntityY(movepivot)*.1,-EntityZ(movepivot)*.1

MoveEntity player,EntityX(movepivot),EntityY(movepivot),EntityZ(movepivot)
If EntityY(player)<0
ycollided=1
	PositionEntity player,EntityX(player),0,EntityZ(player)
	TranslateEntity movepivot,0,EntityY(movepivot)*-2,0
	EndIf
   for x = 1 to countcollisions(player)
    if collisionny(player,x) then ycollided = 1
next

If (KeyHit(29) and (ycollided)) Then TranslateEntity movepivot,0,1.5,0


UpdateWorld
RenderWorld
text 0,0,ycollided
Flip
Until KeyHit(1)



necky(Posted 2003) [#8]
What you need is some kind of a cylindrical collision system for that job. How I'd do it is let Blitz do a usual sphere-to-polygon slide collision. Once it's got it's new position the first thing to do is check to see if the sphere (the sphere being the players collsion) actually did hit a wall (entitycolide)

If it did then what you need to do is push the player back but keep it's new height.

The best thing to do is split your wall collision mesh up from your floor collision and do 2 checks on each. Otherwise you'd be doing a wall check on a floor and you wouldn't be able to tell one from the other.

Well that's how I'd do it anyway's :)

Mike