Corner Collisions acting wierd

Blitz3D Forums/Blitz3D Programming/Corner Collisions acting wierd

Rubiks14(Posted 2005) [#1]
ok this kinda goes with my post in blitz3d newbies forum but i am not getting many more answers on there so made new post. ok well i got my collisions working right with the floor and stuff exept for the corners. when i jump into a corner and hold the foward(or any other direction depends on which way looking), i literaly stick to the corner. or if i hold foward before i jump i won't be able to jump at all. so i was wondering if anybody could help me out with this? here is my code
; set up the graphics
Graphics3D 640,480
;set up the back buffer
SetBuffer BackBuffer()

; some globals
Global PlayerGrav# = 0.0
Global Grav# = 0.2
Global jumped = 0
; collision groups
Global PLAYER = 1
Global SCENERY = 2
Global type_ladders = 3

; create a light
AmbientLight 255,255,255

; create a pivot for the camera
Global camera_pivot = CreatePivot()
; give a radius to the pivot
EntityRadius camera_pivot,7.5
; make a type for the piivot
EntityType camera_pivot,PLAYER
; move the player to the middle of the map
PositionEntity camera_pivot,100,100,100

; create a camera
Global camera = CreateCamera()
; give the camera a distance
CameraRange camera,1,600
EntityType camera,PLAYER

; load the level
Global level = LoadMesh("test.b3d")
ScaleEntity level,15,15,15
EntityType level,SCENERY

; load the gun mesh
Global gun = LoadMesh("gloc.3ds",camera)
; load the gun texture
weapon_tex2 = LoadTexture("glocmap.jpg")
; texture the gun
EntityTexture gun,weapon_tex2
; rotate the gun
RotateEntity gun,12,170,14
; scale the gun
ScaleEntity gun,0.01,0.01,0.01
; position the gun a little behind the camera
PositionEntity gun,1,-1,1.5
; draw the gun last
EntityOrder gun, -1

; collisions
Collisions PLAYER,SCENERY,2,3

Global my_time = CreateTimer(40)

Global old_time = MilliSecs()
; main loop
While Not KeyHit(1)

PositionEntity camera, EntityX(camera_pivot), EntityY(camera_pivot), EntityZ(camera_pivot)

; the player is moving down
PlayerGrav# = PlayerGrav# - Grav#

; move the camera to current gravity force
TranslateEntity camera_pivot,0,PlayerGrav#,0
	
; give gravity to the level
For c = 1 To CountCollisions(camera_pivot)
	If CollisionNY(camera_pivot,c) > 0
		PlayerGrav# = 0.0
		jumped = 0
		; if player hits the ceiling when jumping come back down
		If CollisionNY(camera_pivot,c) < 0 And jumped = 1
			PlayerGrav# = PlayerGrav - Grav#
		EndIf
	EndIf
Next

MovePlayer()
TurnPlayer()

; update the world	
UpdateWorld

WaitTimer(my_time)

; draw the world
RenderWorld

	; FPS
	frames=frames+1
	If MilliSecs()-render_time=>1000 Then fps=frames : frames=0 : render_time=MilliSecs()	
	Text 0,0,fps


; flip the buffers
Flip
; end of main loop
Wend
; end of program
End

Function MovePlayer()

; move the player foward when player presses w
If KeyDown(17) Then MoveEntity camera_pivot,0,0,1
; move the player back when player presses s
If KeyDown(31) Then MoveEntity camera_pivot,0,0,-1
; move the player left when player presses a
If KeyDown(30) Then MoveEntity camera_pivot,-1,0,0
; move the player right when player presses d
If KeyDown(32) Then MoveEntity camera_pivot,1,0,0
; make the player jump if player presses space
If KeyDown(57) And jumped = 0
	; make the player jump
	PlayerGrav# = 2
	; the player has jumped
	jumped = 1
	; flush the keys
	FlushKeys
EndIf

End Function

Function TurnPlayer()

	x_speed#=(MouseXSpeed()-x_speed)/2+x_speed
	y_speed#=(MouseYSpeed()-y_speed)/2+y_speed
	TurnEntity camera,y_speed,0,0,0;global false
	TurnEntity camera_pivot,0,-x_speed,0,1;global true
	RotateEntity camera_pivot, EntityPitch#(camera_pivot), EntityYaw#(camera_pivot), 0     ;z roll correction
    RotateEntity camera, EntityPitch#( camera ), EntityYaw#(camera_pivot), 0          ;Z roll correction
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

End Function


EDIT: oh and also i kinda bounce down ramps. only down them. so if you feel like it you can look at that too but you don't have to.

thanks, Rubiks14


Stevie G(Posted 2005) [#2]
The second part of the gravity code will never be called as it's nested

Try this ...

; give gravity to the level
For c = 1 To CountCollisions(camera_pivot)
	If CollisionNY(camera_pivot,c) > 0
		PlayerGrav# = 0.0
		jumped = 0
	EndIf
	If CollisionNY(camera_pivot,c) < 0 And jumped = 1
		PlayerGrav# = PlayerGrav - Grav#
	EndIf
Next



Rubiks14(Posted 2005) [#3]
that didn't help anything i think that just checked for if the camera hit the ceiling right?


Hujiklo(Posted 2005) [#4]
Hard to see what's happening without being there with you but you could try and change this:

Collisions PLAYER,SCENERY,2,3

to this:

Collisions PLAYER,SCENERY,2,2

...also print your gravity variable to the screen using the 'text' commands so you can check if you actually have gravity or not when you get stuck on the walls - it will help you to eliminate it if it is not the cause of the problem.


Ross C(Posted 2005) [#5]
Do a linepick straight down from your character. If a collision registers, do a linepick down and check the length of the line pick. If the character is off the ground, enable gravity.


Rubiks14(Posted 2005) [#6]
ok i'll try both of those and see if either works, but i can't yet because i'm at work. now just a question ross how would i do a linepick with only the ground(i know how to do linepick just not how your sayin)?

EDIT: wait i know how to do camera pick but i'm sure line pick isn't much different. It would still be nice if you could put some psudocode(i think that is how it's spelt) for me


Stevie G(Posted 2005) [#7]
If you upload the working source and models you'll have more chance of people helping. It should be easy enough to fix but I couldn't be arsed making my own level to test with :)


Rubiks14(Posted 2005) [#8]
ok i will when i get home from work.My current level is just the test level that comes with maplet and you can just take out the gun code because really that is only there for show at this point.


Rubiks14(Posted 2005) [#9]
ok how do you make a link?
EDIT: i think i got it. here is the link to my freewebs page www.freewebs.com/rubiks14
click on FPS source. this is so you can see for yourself what is going on.

another EDIT: hujiklo what you said works yay but now i slide down ramps when i'm standing still on them. anyway you guys can still look at it and see for yourself

again another edit: now this is the most retarded glitch i have ever seen in all of my time playing games or making them. ok there is just one spot where i can walk up the wall when i'm holdin jump, the spot is small and it is the only place that i have seen so far. i will put a different texture on the area in my .zip file so you guys can see what is goin on