over a level

Blitz3D Forums/Blitz3D Beginners Area/over a level

jigga619(Posted 2003) [#1]
Is there a specific line of code that makes your chatacter stay above the ground of a house that your character is in? What code makes your character be able to move up a slope in a level, and not sink through the ground?


DragonMage(Posted 2003) [#2]
The way I did it was to use collision detection. If this is a first-person game, assign the camera an entitytype of one and the object you want to keep your character above a value of 2

camera=createcamera()
house=loadmesh("...")
entitytype house, 2
entitytype camera, 1
collisions 2, 1, 2, 3

Then you may want to move your character up a bit because this type of collision sets your character a bit below the bottom. The last number in the collisions call tells the camera to be pushed up when a collision is detected. This can be used for ramps. If you decide to add gravity, you will have to make the ramps not have a steep incline.

Note: This is completely off the top of my head. You might have to move around the first two numbers in the collisions command.


jhocking(Posted 2003) [#3]
Another way is to use LinePick and/or EntityPick. What I do is a LinePick straight down from the character every frame to detect the ground below him. This way I can also use the various Picked-something commands to get information about the ground detected.


Binary_Moon(Posted 2003) [#4]
"This way I can also use the various Picked-something commands to get information about the ground detected."

-- Of course you could use collision, like normal people, and get exactly the same information.

The line pick would stop your player from falling through the floor but he would be able to walk through walls. Collision is a lot easier and the collision responces return everything that the linepick data can get.


jhocking(Posted 2003) [#5]
"like normal people"
Ha ha, very funny. I use collision detection for walls and stuff of course. The point of doing a LinePick down is to detect properties of the ground below the character whether or not the character is on the ground. Using collision detection for getting information about the ground is only useful when the player is actually colliding with the ground. For a variety of reasons I find it is often useful to know what is below the player when the player is in the air. Come to think of it I would imagine this kind of thing would come up in your game "Rocket Boards" where the player is never touching the ground.


Binary_Moon(Posted 2003) [#6]
:)

"The point of doing a LinePick down is to detect properties of the ground below the character whether or not the character is on the ground"

-- I guess that's fair enough. Can't think of any uses for that though

"Come to think of it I would imagine this kind of thing would come up in your game "Rocket Boards" where the player is never touching the ground."

-- Why? What do I need to know about the ground when the player isn't touching it. I use linepicks for the shadows but that has nothing to do with the collision of the player.


jhocking(Posted 2003) [#7]
LinePicks for placing shadows may not have anything to do with collision but that is certainly one reason you may need information about the ground beneath the player. Frankly none of my reasons have anything to do with collision (which is why collision detection isn't enough) but do need a LinePick, so as long as I'm doing one I may as well use the information. In many cases I simply need to know how high up the player is. Other times I've needed information from the lightmap so that I can darken the character, etc.

For your game obviously just do what you need to and what works. I was imagining something like reacting to what the player is hovering over (eg. the boards handle better over solid ground than over water) but I suppose that isn't very realistic. Now that I'm really thinking about it though I imagine a LinePick to determine altitude every frame would be useful for adjusting the player's altitude over uneven ground.


Rook Zimbabwe(Posted 2004) [#8]
OK I am using a .X model of a castle with ramps to learn on this here idea. I have my camera entity set at 1 and I have the castle entity set at 2.

I have collisions set at 1,2,2,2
I have also tried 1,2,2,3

in no way does the camera go more than about 6 inches up the ramp without stopping.

If someone could email me how to post code here I would be glad to show.

:)


eBusiness(Posted 2004) [#9]
Type [/code] to end a code block, and [code] to start one. It's that simple :)


Rook Zimbabwe(Posted 2004) [#10]
Hmmm OK well I tried to post a small image with those types of commands for a guy that needed a diceimage // no joy! But here goes...

PLEASE keep in mind that this is just "loose learning code"

; FPS Terrain Walkabout
; -------------------

Graphics3D 800,600
SetBuffer BackBuffer()
SeedRnd (MilliSecs())
Global dragon1

campiv = CreatePivot()
camera = CreateCamera(campiv)
PositionEntity camera,200,300,400
CameraRange camera,.1,1500
CameraFogRange camera,10,1300
EntityRadius camera,16
EntityType camera,1

;setup lighting
light=CreateLight()
RotateEntity light,45,45,0
AmbientLight 48,48,48    ; was 32,32,32

; Load Sound for backmusic
dragon1 = LoadSound("media/dragon1.wav")

chnbackground=PlayMusic("media/track05.ogg")


; Load terrain map
terrain=LoadTerrain( "maps/landmap2.jpg" )
; Set terrain detail, enable vertex morphing
TerrainDetail terrain,4800,True
ScaleEntity terrain,30,30,30
grass_tex=LoadTexture( "textures\mossyground1.jpg" )
EntityTexture terrain,grass_tex,0,1


;create ground plane
ground_tex=LoadTexture( "textures\terrain-1.jpg")
ScaleTexture ground_tex,128,128
p=CreatePlane()
EntityFX p,1
PositionEntity p,0,21,0
EntityTexture p,ground_tex
EntityType p,type_ground


;create cloud planes
cloud=LoadTexture( "textures\cloud_2.bmp",3)
ScaleTexture cloud,1000,1000
p=CreatePlane()
EntityTexture p,cloud
EntityFX p,1
PositionEntity p,0,600,0
p=CopyEntity( p )
RotateEntity p,0,0,180


;create water plane
tex=LoadTexture( "textures\wawa1.bmp",3 )
ScaleTexture tex,10,10
p=CreatePlane()
EntityTexture p,tex
EntityBlend p,1
EntityAlpha p,.75
PositionEntity p,0,14,0
EntityFX p,1
	

;cool dragon model!
tex=LoadTexture( "textures\dragon.bmp" )
dragon=LoadMD2( "textures\dragon.md2" )
EntityTexture dragon,tex
PositionEntity dragon,900,40,200
TurnEntity dragon,0,150,0
EntityType dragon,type_character
AnimateMD2 dragon,1,.05,0,84
;0,40  : idle
;40,46 : run
;46,54 : attack
;54,58 : paina
;58,62 : painb
;62,66 : painc
;66,72 : jump
;72,84 : flip
; microphone=CreateListener(camera,100,10,100) ; Create listener, make it child of dragon

;cool castle model!

castle=LoadMesh( "textures\castle1.x" )
PositionEntity castle,999,0,999
EntityFX castle,0
EntityType castle,2
EntityPickMode castle,2
UpdateNormals castle
TurnEntity castle,0,18,0

;cool crate model!
texh=LoadTexture( "textures\wcrate.jpg" )
crate=LoadMesh( "textures\wcrate1.3ds" )
EntityTexture crate,texh
PositionEntity crate,300,40,300
TurnEntity crate,1,120,0
EntityType crate,2


;cool tree model!

tree=LoadMesh( "textures\tree1.x" )
PositionEntity tree,400,0,400
EntityFX tree,0
EntityType tree,2
TurnEntity tree,0,0,0
ScaleEntity tree,.5,.5,.5


tree2=CopyMesh(tree)
ScaleEntity tree2,.25,.25,.25
RotateEntity tree2,0,24,0
EntityType tree2,2
PositionEntity tree2,600,0,320

tree3=CopyMesh(tree)
ScaleEntity tree3,.75,.25,.75
RotateEntity tree3,0,24,0
EntityType tree3,2
PositionEntity tree3,1140,0,2410


CameraFogColor camera, 2, 2, 2

Collisions 1,2,2,2





If KeyHit( 57 )=False Then fog_mode=1-fog_mode : CameraFogMode camera,fog_mode

While Not KeyDown( 1 )
HidePointer

; to use the mouse to look
; need to fix the rollover problem
; probably use a limiter or something

  mxs#=MouseXSpeed()/4
  mys#=MouseYSpeed()/4
  xa#=(xa#-mxs#)Mod 360
  ya#=(ya#+mys#)Mod 360
 
  MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
  RotateEntity camera,ya#,xa#,0
  

x#=EntityX(camera)
y#=EntityY(camera)
z#=EntityZ(camera)

terra_y#=TerrainY(terrain,x#,y#,z#)+40 ; this last number is height 34 - 64



PositionEntity camera,x#,terra_y#,z#


If KeyDown( 205 )=True Then TurnEntity camera,0,-5,0
If KeyDown( 203 )=True Then TurnEntity camera,0,5,0
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-5
If KeyDown( 200 )=True Then MoveEntity camera,0,0,5
If KeyDown( 26 )=True Then MoveEntity camera,5,0,0
If KeyDown( 27 )=True Then MoveEntity camera,-5,0,0
If KeyDown( 57 )=True Then PlaySound (dragon1)
If EntityCollided(castle,2) Then 
AlignToVector castle,CollisionNX(castle,1),CollisionNY(castle,1),CollisionNZ(castle,1),2 
temp=CollisionNZ(castle,1) 
col=1 
Else 
col=0 
End If





UpdateWorld()

RenderWorld()

Text 0,0,"Use cursor keys to move about the terrain [ESC] to quit"

Flip


Wend

End



Ross C(Posted 2004) [#11]
You could try using collision response 3 instead of 2 in your line:

Collisions 1,2,2,2



Rook Zimbabwe(Posted 2004) [#12]
Actually I have tried that too... no joy!


Rook Zimbabwe(Posted 2004) [#13]
I don't figure this is a Blitz3d bug, I think I just need to learn more about mousemovement and jump stuff. In my ignorant opinion that is a keystone of any FPS. The look/move/jump is as important as the fire/weaponselect/use stuff.

That is why I just started there. Seeing what others have done and grokking why. If it is at all "grok-able"

I sure do wish Blitz and B3D were in book format.

If you cut out all the objects but the terrainmap and the castle (use the one from the blitz3d demo) can YOU get it to walk up a ramp?

Perhaps I missed an update?


Ross C(Posted 2004) [#14]
Nothing to do with an update.

What exactly is your problem?


Rook Zimbabwe(Posted 2004) [#15]
Not to put too fine a point on it but in the cubed demo you can actually scale the walls but you can only scale so high and then you stop. I have been looking at the FPS Free code and at that code and I can't really see the /KEY/ I know I am doing something not right and it is probably in my movement section.


Ross C(Posted 2004) [#16]
Ok, please explain the problem you are having plz. :)


Rook Zimbabwe(Posted 2004) [#17]
Sorry Ross, I know this is confusing and I think I have found out WHY I am having this problem... I can't think of how to fix it though!

The problem comes with TerrainY. I used that to ride the camera along the ground over the bumps. I thought it looked very much better than throwing in some seasick inducing head bobble function.

in this line of code:

terra_y#=TerrainY(terrain,x#,y#,z#)+40 ; this last number is height 34 - 64

PositionEntity camera,x#,terra_y#,z#


I read the terrain map I had created (individually from the endless ground map there posted) and thereby got into this fix.

You see I want a really big terrain map with hills and lakes and such and I wan to be able to have a .X mesh or two to wander in and out of.

Maybe if it was a .B3D file? I could loadAnimMesh on it and it would react differently?


Ross C(Posted 2004) [#18]
Try giving the camera a collision type, and forcing it down on the terrain, using collision response 3.


eBusiness(Posted 2004) [#19]
Ah, that helped, you manually locate the player relative to the ground, so if the player is inside the castle he will be forced down by this command. Skip the code snippet that you just posted, include gravity, and use the same type of collisions with both the ground and the castle.


jhocking(Posted 2004) [#20]
You guys won't fool me this time. I recognize this as a thread from a year ago. Why do people keep resurrecting old threads?


eBusiness(Posted 2004) [#21]
Hmmm, didn't notice. But I'll guess that Rook did a search for this topic in order to try to find an answer, rather that just posting. When he didn't find any answer he posted here, because it was somehow related.


Rook Zimbabwe(Posted 2004) [#22]
Actually I resurrected the thread after searching for it and not finding the help that I needed even in it... [that statement refers to the contents of the original thread ONLY!] Ross C and eBusiness have helped me and yes That worked from both of you... Thank you!