Objekt hüpft auf und ab
Übersicht

![]() |
canny771Betreff: Objekt hüpft auf und ab |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hey Leute,
ich hab mal wieder ein Problem. Dieses Mal hab ich mit einer Heightmap ein Terrain erstellt und eine Schwerkraft simuliert. Nun, ich rätsle schon seit Tagen warum mein Charakter immer auf und ab hüpft. Was muss ich bei der Kollision verändern, damit er nach einer Kollision nicht immer nach oben springt (immer eine Einheit (Pixel?!))? Immer wenn mein Objekt mit dem Terrain kollidiert springt es nach oben. Thx für eure Hilfe. Code: [AUSKLAPPEN] Graphics3D 800,600,32
SetBuffer BackBuffer() SeedRnd MilliSecs() HidePointer() Global CanJump=1 Global Mesh MoveMouse 400,300 ;Physikengine Global entity_col=1 Global obstacle=2 Collisions entity_col,obstacle,2,3 Collisions obstacle,entity_col,3,3 ;Before game Starts CreateSkyBox() Global Terrain=LoadTerrain ("Heighmap3.bmp") TerrainDetail terrain, 4000, True ScaleEntity terrain, 1, 50, 1 PositionEntity terrain,-1024,0,-1024 ;Objects Global markio=LoadAnimMesh ("Markio\Mariorun.X") ScaleEntity markio,1,1,1 Global ani1= LoadAnimSeq (markio,"Markio\Mariorun.X") Global Floor=CreatePlane() ;Textures Global floortexture=LoadTexture ("Floor.bmp") ScaleTexture floortexture,50,50 Global shadowtex=LoadTexture ("Shadow1.bmp",4) ;Sprites Global aimer=LoadImage("aimer.bmp") Global pointer=LoadImage ("Pointer2.bmp") Global shadow = CreateSprite () EntityAlpha shadow,0.4 SpriteViewMode Shadow,2 ScaleSprite shadow,5,5 ;Cam Light/Shadows cam = CreateCamera(markio) Global light=CreateLight() TerrainShading terrain,1 ;Paint EntityTexture Floor,floortexture EntityTexture terrain,floortexture EntityTexture shadow,shadowtex ;Movements ;MoveEntity terrain,0,30,0 MoveEntity cam,0,30,-100 MoveEntity markio,40,110,50 MoveEntity shadow,-0.5,-0.9,0 RotateEntity shadow,90,0,0 MoveEntity mesh,0,0,-200 RotateEntity light, 135, 0, 0 ;Parent/Child EntityParent mesh,markio ;Collisions EntityType markio,entity_col EntityType Terrain,obstacle ;Position ;Char Global CharXPos=0 Global CharYPos=0 Global CharZPos=0 Global Jumper Global Down Global Jumpspeed=10 Global CarGrav#=1 Repeat RenderWorld() UpdateWorld() grav(markio) MoveChar() Schatten() MoveCam() UpdateChar() Text 10,10,EntityY(terrain) Flip Until KeyDown (1) End Function MoveChar() If CanJump=1 If KeyDown (57) Jumper=1 canjump=0 EndIf EndIf If KeyDown (17) MoveEntity markio,0,0,2 ElseIf KeyDown (31) MoveEntity markio,0,0,-1 Else Animate markio,1,0.7 EndIf If KeyDown (30) TurnEntity markio,0,4,0 TurnEntity mesh,0,-4,0 EndIf If KeyDown (32) TurnEntity markio,0,-4,0 TurnEntity mesh,0,4,0 EndIf End Function Function MoveCam() DrawImage pointer,MouseX(),MouseY() If MouseX()<50 EndIf If MouseX()>750 EndIf End Function Function UpdateChar() If Jumper=1 Jump() EndIf End Function Function Jump() MoveEntity markio,0,Jumpspeed,0 Jumpspeed=Jumpspeed-1 If Jumpspeed=0 Jumper=0 Jumpspeed=15 EndIf End Function Function CreateSkyBox() Mesh = CreateMesh() Brush = LoadBrush( "sky_fr.bmp", 49 ) Surface = CreateSurface( Mesh, Brush ) AddVertex( Surface, -100, +100, -100, 0, 0 ) AddVertex( Surface, +100, +100, -100, 1, 0 ) AddVertex( Surface, +100, -100, -100, 1, 1 ) AddVertex( Surface, -100, -100, -100, 0, 1 ) AddTriangle( Surface, 0, 1, 2 ) AddTriangle( Surface, 0, 2, 3 ) FreeBrush( Brush ) Brush = LoadBrush( "sky_lf.bmp", 49 ) Surface = CreateSurface( Mesh, Brush ) AddVertex( Surface, +100, +100, -100, 0, 0 ) AddVertex( Surface, +100, +100, +100, 1, 0 ) AddVertex( Surface, +100, -100, +100, 1, 1 ) AddVertex( Surface, +100, -100, -100, 0, 1 ) AddTriangle( Surface, 0, 1, 2 ) AddTriangle( Surface, 0, 2, 3 ) FreeBrush( Brush ) Brush = LoadBrush( "sky_bk.bmp", 49 ) Surface = CreateSurface( Mesh, Brush ) AddVertex( Surface, +100, +100, +100, 0, 0 ) AddVertex( Surface, -100, +100, +100, 1, 0 ) AddVertex( Surface, -100, -100, +100, 1, 1 ) AddVertex( Surface, +100, -100, +100, 0, 1) AddTriangle( Surface, 0, 1, 2 ) AddTriangle( Surface, 0, 2, 3 ) FreeBrush( Brush ) Brush = LoadBrush( "sky_rt.bmp", 49 ) Surface = CreateSurface( Mesh, Brush ) AddVertex( Surface, -100, +100, +100, 0, 0 ) AddVertex( Surface, -100, +100, -100, 1, 0 ) AddVertex( Surface, -100, -100, -100, 1, 1 ) AddVertex( Surface, -100, -100, +100, 0, 1 ) AddTriangle( Surface, 0, 1, 2 ) AddTriangle( Surface, 0, 2, 3 ) FreeBrush( Brush ) Brush = LoadBrush( "sky_up.bmp", 49 ) Surface = CreateSurface( Mesh, Brush ) AddVertex( Surface, -100, +100, +100, 0, 1 ) AddVertex( Surface, +100, +100, +100, 0, 0 ) AddVertex( Surface, +100, +100, -100, 1, 0 ) AddVertex( Surface, -100, +100, -100, 1, 1 ) AddTriangle( Surface, 0, 1, 2 ) AddTriangle( Surface, 0, 2, 3 ) FreeBrush( Brush ) Brush = LoadBrush( "sky_dn.bmp", 49 ) Surface = CreateSurface( Mesh, Brush ) AddVertex( Surface, -100, -100, -100, 1, 0 ) AddVertex( Surface, +100, -100, -100, 1, 1 ) AddVertex( Surface, +100, -100, +100, 0, 1 ) AddVertex( Surface, -100, -100, +100, 0, 0 ) AddTriangle( Surface, 0, 1, 2 ) AddTriangle( Surface, 0, 2, 3 ) FreeBrush( Brush ) FlipMesh( Mesh ) EntityOrder( Mesh, 10 ) ScaleEntity( Mesh, 5, 5, 5 ) EntityFX( Mesh, 1 ) Return Mesh End Function Function grav(markio) If Not EntityCollided(markio,2) TranslateEntity markio,0,-CarGrav#,0 CarGrav#=CarGrav#+0.25 ; Text 0,0,"1" If cargrav#>5 Then cargrav#=5 Else canjump=1 Text 0,0,"0" CarGrav=1 EndIf End Function Function Schatten() PositionEntity shadow,EntityX(markio),TerrainY(terrain,EntityX(markio),EntityY(markio),EntityZ(markio))+1,EntityZ(markio) End Function |
||
Hangman |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ganz blöde Idee aber änder doch mal die Reihenfolge, erst die Gravitation und dann UpdateWorld()...
War jetzt die erste Idee die mir nach 1sek kam und auch sonst nicht weiter überdacht ist ![]() |
||
Ich habe Berthold gebrochen. |
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
Du solltest vor allem die Reihenfolge von RenderWorld( ) und UpdateWorld( ) verändern... erst UpdateWorld() dann Renderworld( )
mg ToeB |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
![]() |
canny771 |
![]() Antworten mit Zitat ![]() |
---|---|---|
O man -.- natürlich, ich war so auf den Fehler in der Gravitation fixiert, dass mir das nicht mal aufgefallen ist ![]() Du hast natürlich Recht, ToeB. Tut mir Leid euch mit einem derart peinlichen Fehler zu belästigen ![]() Danke für eure Hilfe |
||
Hangman |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
also hüpfen beseitigt dadurch? | ||
Ich habe Berthold gebrochen. |
![]() |
canny771 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Jup^^ | ||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group