y am i walking on walls?

Blitz3D Forums/Blitz3D Beginners Area/y am i walking on walls?

Rubiks14(Posted 2005) [#1]
i have 2 questions:
1. y am i walking on the walls
2. y can't i jump every time i press space

if anybody could answer those that would be great
thanks, Rubiks14

; set up the graphics
Graphics3D 800,600
;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

; create a light
AmbientLight 255,255,255

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

; 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,10,0,10

; load the level
Global level = LoadMesh("my little map.x")
ScaleEntity level,20,20,20
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
Collisions SCENERY,PLAYER,2,3

; main loop
While Not KeyHit(1)


MovePlayer()
TurnPlayer()

; the player is moving down
PlayerGrav# = PlayerGrav# - Grav#
	
; give gravity to the level
If EntityCollided(camera_pivot,SCENERY)
	; player gravity is 0
	PlayerGrav# = 0.0
	; player not jumping
	jumped = 0
EndIf
	
; position the camera with the pivot
PositionEntity camera,EntityX#(camera_pivot),EntityY#(camera_pivot),EntityZ#(camera_pivot)

; move the camera to current gravity force
TranslateEntity camera_pivot,0,PlayerGrav#,0

; update the world	
UpdateWorld
; draw the world
RenderWorld
; 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,2
; 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,-2,0,0
; move the player right when player presses d
If KeyDown(32) Then MoveEntity camera_pivot,2,0,0
; make the player jump if player presses space
If KeyHit(57) And jumped = 0
	; make the player jump
	PlayerGrav# = 3
	; the player has jumped
	jumped = 1
EndIf

End Function

Function TurnPlayer()

; turn the player with the mouse
TurnEntity camera_pivot,0,-MouseXSpeed(),0
; make the player look up and down
TurnEntity camera,MouseYSpeed(),0,0
; z roll correction
RotateEntity camera_pivot,EntityPitch#(camera_pivot),EntityYaw#(camera_pivot),0
; z roll correction
RotateEntity camera,EntityPitch#(camera),EntityYaw#(camera_pivot),0
; move the mouse to the center of the screen
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

End Function



Gauge(Posted 2005) [#2]
Well can't actually run the program, but I think your overdoing your collisions, your running player to scenery and scenery to player. Since your scenery does not move it doesn't check scenery to player collision so take that line out.

Try that first, if it doesn't work change your collision method to 2 instead of 3.

One other thing that you might try is, collision method 3 stops a mesh from sliding down another mesh, but not from oing up, thus if your possibly 1% off on your wall it could just be walking up it. Maybe not, but perhaps try tilting the top of the wall in just a touch and this might also stop it.

As far as jumping change keyhit(57) to keyhit(57) or keydown(57). Even when using flush keys I have this problem, it will sometimes read the keys as keydown, even if you hit them as fast as you possibly can. that should fix that problem.

I'm no expert, but i suggest using floor/ground/terrains as a different mesh and type. I don't think its a good idea to make it all one mesh. Anyone back me up here?


Rubiks14(Posted 2005) [#3]
ok my jumping is fixed but i am still walking up the walls, part of the reason could be my retarded level that i just threw together to test this out but i tried it with another level and it did to so i guess that isn't it


another thing, i only walk on the walls while i'm holding down the jump key


WolRon(Posted 2005) [#4]
another thing, i only walk on the walls while i'm holding down the jump key

Well, then that's why!

You'll have to change your code, so that it pushes you away from the wall when you're in the air just enough to allow you to fall.

2. y can't i jump every time i press space

y = why
i = I

This isn't a cellphone, so please type proper.


jfk EO-11110(Posted 2005) [#5]
you could also add (parent) a pivot between the feet, with a small radius. only when this pivot is near the ground (use a linepick) you should allow jumping.
y=why? wow I didn't know that.


Rubiks14(Posted 2005) [#6]
I don't understand what you are saying, could you give an example plz?
thanks,Rubiks14