EntityOrder
Blitz3D Forums/Blitz3D Beginners Area/EntityOrder
| ||
Im using something built with maplet(inside of a a building). inside the game, ive got the arrow and the bow on the screen with the same code i used for outside the building. i run it... and the bow AND arrow isn't there! so i change the entity order of both of them to: -1 fixed it, except now, when the arrow is fired, and it goes through the building, it doesn't disapear... it just shows it going and going until it's out of range for viewing. im assuming this is because of the EntityOrder command, i just don't know how to fix it... any ideas? |
| ||
entity order tells the engine where it should draw the geometry, kind of like Photoshop Layers. What you did is, you told the engine to draw the bow and arrow in front of everything else so the arrow never disappears behind objects despite the fact that its still moving in 3D space. Since I don't code in blitzbasic I don't know what the default entity order settings are. What I use Entity order for are things like 3D HUDS and UI's built in 3dsmax that I want attached to the camera and drawn in front of everything else. Or things like the sky which I don't want to be invinately large so its attached to the camera and has the entity order set to allway draw first behind everything else in the scene. can be used for all sorts of things if you use a little imagination. You shouldn't really need to use entityorder for the bow and certainly not the arrow, which you will want to have bass behind objects in your scene. |
| ||
ok, thank you. do u know a better way to make the arrow appear? the maplet program is placed in front of the arrow, i just don't know of a better way to make it appear... |
| ||
Post your code so that we can see where the problem lies. |
| ||
Graphics3D 800,600,16,0 Const CollisionType_Camera = 1 Const CollisionType_Level = 999 Collisions CollisionType_Camera,CollisionType_Level,2,2 Collisions ArrowT,CollisionType_Level,2,1 Global Mouse_X_Speed# Global Mouse_Y_Speed# Global Camera_VelX# Global Camera_VelZ# Global Camera_Pitch Global Camera_Yaw Global arrow_in_air = False Global shottimer = MilliSecs() Global arrow_speed = 15 Global pum = LoadSound("bowfire2.wav") SetBuffer BackBuffer() light = CreateLight() Global cam=CreateCamera() CameraRange Cam,0.1,50000 PositionEntity cam,1,0.8,0.5 CameraZoom Cam,0.8 EntityType cam,CollisionType_Camera EntityRadius cam,0.1 Global weapon2 = LoadMesh("bow.3ds") weapon_tex2 = LoadTexture("Bow_tex.bmp") EntityTexture weapon2,weapon_tex2 ScaleEntity weapon2,1,1,1 EntityOrder weapon2,-1 Global arrow = LoadMesh("arrow.b3d") EntityType arrow,ArrowT ScaleEntity arrow,1.2,1.2,1.2 RotateEntity arrow,0,180,0 EntityRadius arrow,0.1 EntityOrder arrow,-1 world = LoadMesh("InnerCityHall.b3d") EntityType world,CollisionType_Level PositionEntity world,0,0,0 While Not KeyHit(1) UpdateWorld RenderWorld Text 0,10,"X: " + EntityX(cam) Text 0,25,"Y: " + EntityY(cam) Text 0,40,"Z: " + EntityZ(cam) Text 400,0, "Health" + health Flip PositionEntity cam,EntityX(cam),0.8,EntityZ(cam) Proc_UpdateGame() Wend Function Proc_Freelook(CamEntity,Velocity#,Speed#) Mouse_X_Speed#=MouseXSpeed()*0.5 Mouse_Y_Speed#=MouseYSpeed()*0.5 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 Camera_Pitch=Camera_Pitch+Mouse_Y_Speed# Camera_Yaw=Camera_Yaw+Mouse_X_Speed# RotateEntity CamEntity,Camera_Pitch,-Camera_Yaw,0 If KeyDown(203) Then Camera_VelX=Camera_VelX-Speed#/100000 ElseIf KeyDown(205) Camera_VelX=Camera_VelX+Speed#/100000 EndIf If KeyDown(208) Then Camera_VelZ=Camera_VelZ-Speed#/100000 ElseIf KeyDown(200) Camera_VelZ=Camera_VelZ+Speed#/100000 EndIf Camera_VelX=Camera_VelX/velocity# Camera_VelZ=Camera_VelZ/velocity# MoveEntity CamEntity,Camera_VelX,0,Camera_VelZ If KeyDown(200) Then MoveEntity CamEntity,0,0,Speed# / 20 EndIf If KeyDown(208) Then MoveEntity CamEntity,0,0,-Speed# / 20 EndIf If KeyDown(205) Then MoveEntity CamEntity,Speed# / 20,0,0 EndIf If KeyDown(203) Then MoveEntity CamEntity,-Speed# / 20,0,0 EndIf End Function Function Proc_UpdateGame() Proc_Freelook(Cam,1.05,0.5) RotateEntity weapon2,EntityPitch(cam),EntityYaw(cam)+5,0,EntityRoll(cam) PositionEntity weapon2,EntityX(cam)+Sin(EntityYaw(cam)),EntityY(cam)-1,EntityZ(cam)-Cos(EntityYaw(cam)) MoveEntity weapon2,-16,0,0 MoveEntity weapon2,0,0,24 If MouseHit(1) Then If arrow_in_air = False PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2) RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2) PlaySound(pum) arrow_in_air = True ShowEntity arrow ShotTimer = MilliSecs() arrow_hit = False End If End If If arrow_in_air = False PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2) RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2) End If MoveEntity arrow,0,0,arrow_speed ;If EntityCollided(arrow,CollisionType_Level) ; PositionEntity arrow,-5000,-5000,-5000 ;End If If MilliSecs() > ShotTimer + 2000 arrow_in_air = False ShowEntity Arrow End If End Function |
| ||
First you can avoid all of this:RotateEntity weapon2,EntityPitch(cam),EntityYaw(cam)+5,0,EntityRoll(cam) PositionEntity weapon2,EntityX(cam)+Sin(EntityYaw(cam)),EntityY(cam)-1,EntityZ(cam)-Cos(EntityYaw(cam)) MoveEntity weapon2,-16,0,0 MoveEntity weapon2,0,0,24by just parenting weapon2 to the camera. In this part: If MilliSecs() > ShotTimer + 2000 arrow_in_air = False ShowEntity Arrow End IfYou probably meant for ShowEntity to be HideEntity. Every frame you set the arrow next to the bow: If arrow_in_air = False PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2) RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2) End If MoveEntity arrow,0,0,arrow_speedbut then you move the arrow 15 units (arrow_speed) ahead. Is this correct? It doesn't appear to be. This might be your problem. Try changing that and rerunning it without the entityorder commands. |
| ||
first part: yeah ill change that, thx on the second part: no, actually i meant it to be ShowEntity, the reason being something i had to do awhile ago to make it work, but i found a better way. now i don't really need it anymore... |
| ||
I wasn't done updating my post. Read the last part. |
| ||
i changed it to where it only moves the arrow forward when arrow_in_air = true, runs the same way: when drawn normal, the arrow doesn't show at all, and when drawn last, the arrow is still shown after it goes through the wall the code worked on my other level perfectly, but it's not working with the maplet level |
| ||
CameraRange Cam,0.1,50000 By the way, this is probably too extreme. For better results, you should maybe set it to something similar to 1,5000. But really, it depends on the units you are using. Right now it looks like you are using a small scale since you are moving things around 10-25 units so you wouldn't want the first parameter to CameraRange to be so small (.1). |
| ||
yeah I found that extreme camera ranges causes graphics glitches, as Blitz precision goes off the wider the camera range so the larger the near and smaller the far the better. Otherwise you get more pronounced polygon Z sorting issues. Precision decreases the further away from the world origin you are, and its not recommended to have anything in your game further than 10,000 blitz units from 0,0,0 |
| ||
i played around with it, and when i increase the small camera range, it makes teh walls disapear when the character walks through the hallway, i don't see a difference with the long camera range... |
| ||
lissesul, probably because your level geometry is tiny. If it works then it works :) I was just pointing out one of blitz's problems that relates to the camera ranges. If you use a viewer like the B3D viewer in pipeline which lets you specify ranges you can see the effects pretty easily. you should check what scale your level geometry is built to. I have mine as 1 blitz unit = 1 meter. So the largest level I can do would be about 10 kilometers, not that I'll be doing one that large. But my current level I'm working on is 500x500 meters and has the camera set to 1:500 you should really try an fit your camera range to the scale of your level as longer ranges can slow thing down and cause visual glitches, same with fog etc. also sometimes gometry cn load up with the normals cacing the wrong way so the model is infact insid out, surprisingly it can sometimes be hard to tell lol. |
| ||
could it be something to do with maplet? because the arrow and bow both showed up fine on the outdoor level made with TerraEd |
| ||
Try narrowing down the problem. For instance, use the exact same code you are using now, but don't load the map and then see if you can see the bow and arrow. Or try 'holding' the bow or arrow furthur from the camera and see if they then show up. Or try rotating the bow and arrow around their axis a little bit every frame (for testing purposes) to see if something happens. Or try a camerarange of something like .01/100 just to see if the bow and arrow are being clipped by the longer camerarange. |
| ||
ok, i took out the maplet world, and they both showed up... i parented the bow further from the bow, with the maplet level loaded, and neither the bow or arrow showed up. i spun the bow a little bit every frame, and neither showed up, i lowered the camerarange to .01,100 and neither showed up... =/ it seems to me that the maplet world is drawn over the arrow and bow... the only way that i know of to change that is the EntityOrder command, but, like i said before, that makes the arrow be drawn in front of the wall, even after the arrow passes through it. |