Collisions : - (
Blitz3D Forums/Blitz3D Programming/Collisions : - (
| ||
Hi guys, i wondering if anyone could help me with this problem i have. I can't seem to get a collision happening here can anyone please have a look at my code and help me out. Thanks guys for any help BLUE Heres the code: Graphics3D 1024,768 SetBuffer BackBuffer() ;WireFrame True cam=CreateCamera() light=CreateLight() scene=LoadAnimMesh("test.3ds") ScaleEntity scene,.1,.1,.1 PositionEntity scene,0,-20,200 ScaleEntity man,.1,.1,.1 PositionEntity man,0,-20,200 man=LoadMesh("man.3ds") Global lift=FindChild(scene,"lift") ;variables ;collision user=1 wall=2 ;player player_resetx#=EntityX(man) ;save players start position player_resety#=EntityY(man) ;for resetting player player_x#=EntityX(man) player_y#=EntityY(man) player_grip#=200 ;players gripping strength state=1 ;not dead yet :-) ;lift Global lift_resety#=EntityY(lift) ;save lift start position Global lift_y#=EntityY(lift) ;for resetting lift Global lift_direction=1 ;head downwards Global lift_speed#=2 ;self explanatory ;-) ;collision EntityType man,user EntityRadius man,3000 EntityType lift,wall Collisions user,wall,2,2 While Not KeyDown(1) PointEntity cam,lift player_grip=player_grip-.5 ;player control If KeyHit(200) player_grip=player_grip+.3 EndIf If player_grip<0 Then player_y=player_y-.6 PositionEntity man,EntityX(man),player_y,EntityZ(man) PositionEntity lift,EntityX(lift),lift_y,EntityZ(lift) movelift UpdateWorld RenderWorld Rect 0,600,player_grip,10 Text 0,580,"GRIP METER" Text 0,100,(EntityCollided(man,wall)) Text 0,0,EntityY(lift)+" "+player_y Flip Wend End Function movelift() If lift_direction=1 And lift_y>(lift_resety-800) Then lift_y=lift_y-lift_speed If lift_direction=1 And lift_y=<(lift_resety-800) Then lift_direction=0 If lift_direction=0 And lift_y<lift_resety Then lift_y=lift_y+lift_speed If lift_direction=0 And lift_y=>lift_resety Then lift_direction=1 End Function |
| ||
You want a collision between the 'moving' lift and the character yeah? Collision with moving objects doesn't work (at least not 100%). Sphere to sphere is fine (although the spheres don't ush each other) but the other collision types are rather dodgy. You would be best off working out a way to write this for yourself. |
| ||
You see the thing is, that he will fall through the lift even when it's stationary. Any ideas? Thanks BLUE |
| ||
have a look at this Code archives/3D Graphics/Moving Platforms demo it might help dave |
| ||
I can't test it without the meshes, but that man's EntityRadius looks HUGE! Could be the problem...? |
| ||
Thanks guys, i'll give it another shot and use your kind avice. :-) Thanks again BLUE |