Game doesn't work on new pc with Blitz3d 1.108 ver
Archives Forums/Blitz3D Bug Reports/Game doesn't work on new pc with Blitz3d 1.108 ver
| ||
I had a first person shooter working on my old computer with old version of Blitz3d. Since I ported and recompiled it on my new pc with a GTX970 graphics card the player or gun doesn't respond corrrectly to scancode inputs and gun and camera don't rotate by same amounts (1 deg) as they did before. The up and down keys only respond some of the time so no fwd/rear movements. On the new pc, I recompiled everything using version 1.108. Any one got a clue whats changed to produce these errors. |
| ||
Try compiling with the version that it has worked with, you can download it under Account->Product Updates. It might look like a lot has changed since then. |
| ||
Please provide a simplified code example to demonstrate the problem so that we can also see it on our computers, if you can't, the problem is most likely some error(s) in your code... |
| ||
I used following code in main while loop to turn and move camera(cam1), gun & a bullet (in the gun) as per keystrokes. All three items were initialised at same position prior to while loop :- ; move & turn gun as per requirement (camera, cam1 and bullet should rotate the same amount) If KeyDown( 205 )=True Then TurnEntity gun,0,-2,0 : TurnEntity cam1,0,-2,0 : TurnEntity bullet,0,-2,0 If KeyDown( 203 )=True Then TurnEntity gun,0,2,0 : TurnEntity cam1,0,2,0 : TurnEntity bullet,0,2,0 If KeyDown( 208 )=True Then MoveEntity gun,0,0,-0.06 If KeyDown( 200 )=True Then MoveEntity gun,0,0,0.06 ; make camera and bullet follow gun by stealing its coordinates PositionEntity cam1,EntityX(gun),EntityY(gun),EntityZ(gun) PositionEntity bullet,EntityX(gun),EntityY(gun),EntityZ(gun) ; move camera a little behind and above gun MoveEntity cam1,0,0.5,-0.8 |
| ||
The reason I used the latest version is because , when I ported the old executible, nothing worked at all, until I recompiled with version 1.108. I haven't recompiled with old version, i don't think... |
| ||
As i said, if you can't provide a simple code example to demonstrate the problem, that we can run on our computers, it is probably some error(s) in your code... Also note that entityx(), entityy(), entityz(), entitypitch(), entityaw(), entityroll(), positionentity(), rotateentity(), can be related to the global or to the local position/orientation of the entity. So if you want an entity to be positionned/oriented like another entity in the 3d world, you want to add the parameter "true" at the end of each function. (read the docs) some functions that i use for that : Function PositionEntityLikeOtherEntity(Entity,OEntity) PositionEntity(Entity,EntityX(OEntity,True),EntityY(OEntity,True),EntityZ(OEntity,True),True) End Function Function RotateEntityLikeOtherEntity(Entity,OEntity) RotateEntity(Entity,EntityPitch(OEntity,True),EntityYaw(OEntity,True),EntityRoll(OEntity,True),True) End Function Function PositionRotateEntityLikeOtherEntity(Entity,OEntity) PositionEntity(Entity,EntityX(OEntity,True),EntityY(OEntity,True),EntityZ(OEntity,True),True) RotateEntity(Entity,EntityPitch(OEntity,True),EntityYaw(OEntity,True),EntityRoll(OEntity,True),True) End Function |
| ||
In your code example i don't see any relation to delta timing. If your new pc is much different, performance wise, you will notice this in the behaviour of your entitys. |
| ||
Thanx for your inputs Remid and MikeHart. You have to bear with me. I'm a complete newbie amateur. Here's a extremely cut down version for you to run, with no imported meshes or textures (so you can't really see if you're moving). The gun is now a rotated cylinder, not an imported mesh. Unfortunately, on my computer at least, this misbehaves even more than my full version because it shoots off in Z direction and sometimes the camera loses the gun object. ; CameraViewport Example ; ---------------------- Graphics3D 640,480 SetBuffer BackBuffer() ; font for output text font = LoadFont("courier",6) SetFont font ascending = 0 ; set ascending parameter (-1 (descending), 0 (neither), 1 (ascending)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Set collision type values type_character=1 type_scenery=2 ; Create a camera cam1=CreateCamera() EntityType cam1,type_character ; set cameras initial position PositionEntity cam1,-40.0,-0.8,-12.0,True ; set fog CameraFogMode cam1,1 CameraFogRange cam1,10,2000 CameraFogColor cam1,0,255,0 ; set camera range 5000 was 25 CameraRange cam1,0.001,5000 ; Set the camera's viewport so that it fills the screen CameraViewport cam1,0,0,GraphicsWidth(),GraphicsHeight() ; calculate centre point on screen gw = GraphicsWidth()/2 gh = GraphicsHeight()/2 ;light1 light=CreateLight() ; create infinite floor plane plane=CreatePlane() EntityType plane,type_scenery EntityColor plane,0,100,0 PositionEntity plane,0,-1,0 ; create infinite sky plane plane2=CreatePlane() EntityType plane2,type_scenery EntityColor plane2,0,0,100 PositionEntity plane2,0,50,0 RotateEntity plane2,180,0,0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Player is represented by his weapon ; ; make a gun (the camera/player will be made to follow this gun) ; place these near building5 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; create gun object ( a rotated cylinder, was an imported gun mesh .x file ) gun=CreateCylinder() EntityType gun,type_character PositionEntity gun,-40.0,-0.8,-12.0 EntityColor gun,155,0,75 RotateEntity gun,90,0,0 ScaleEntity gun,0.05,0.3,0.05 EntityRadius gun,0.425 ; create bullet object ( a stretched sphere. to remain inside gun ) bullet=CreateSphere() EntityType bullet,type_character EntityColor bullet,255,0,0 EntityRadius bullet,0.3 PositionEntity bullet,-40.0,-0.8,-12.0 MoveEntity bullet,0,0,-0.5 ScaleEntity bullet,0.04,0.04,0.4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; buildings (EntityColor has 3 RGB values, values less than 255 darkens the buildings) ; building 1 ( a simple cube, was an imported mesh .x file ) building1=CreateCube() ScaleEntity building1,0.005,0.005,0.005 EntityType building1,type_scenery PositionEntity building1,-7,-1,5 EntityColor building1,155,0,0 ; Set collision method and response values method=2 response=2 method_info$="sphere-to-polygon" response_info$="slide1" ; prevy# is guns (or players) previous Y value prevy# = EntityY(gun) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ; ; ; ; start main engine loop ; ; ; ; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While Not KeyDown( 1 ) ; add a bit of gravity ; determine if gun is descending or ascending ; dely# = EntityY(gun) - prevy# If dely# > 0 MoveEntity gun,0,-0.01,0 ; if ascending use low gravity Else MoveEntity gun,0,-0.095,0 ; if descending use higher gravity EndIf ; set prevy# to current Y prevy# = EntityY(gun) ; move & turn gun as per requirement (camera, cam1 and bullet should rotate the same amount) If KeyDown( 205 )=True Then TurnEntity gun,0,-2,0 : TurnEntity cam1,0,-2,0 : TurnEntity bullet,0,-2,0 If KeyDown( 203 )=True Then TurnEntity gun,0,2,0 : TurnEntity cam1,0,2,0 : TurnEntity bullet,0,2,0 If KeyDown( 200 )=True Then MoveEntity gun,0,0,0.06 If KeyDown( 208 )=True Then MoveEntity gun,0,0,-0.06 ; make camera and bullet follow gun by stealing its coordinates PositionEntity cam1,EntityX(gun,True),EntityY(gun,True),EntityZ(gun,True) PositionEntity bullet,EntityX(gun,True),EntityY(gun,True),EntityZ(gun,True) ; move camera a little behind and above gun MoveEntity cam1,0,0.5,-0.8 ; try to jump if SPACEBAR hit If KeyHit(57) Then TranslateEntity gun,0,0.7,0 ; Enable Collisions between type_character and type_scenery and type_character and type_door Collisions type_character,type_scenery,method,response EntityRadius cam1,0.01 ; Perform collision checking UpdateWorld ; render world RenderWorld ; output absolute X/Y/Z Coordinates Text 0,15," x# =" + EntityX(gun) Text 0,30," y# =" + EntityY(gun) Text 0,45," z# =" + EntityZ(gun) Text 0,60,"dely# =" + dely# Flip Wend End |
| ||
I guess you will spot my poor technique and will suggest parenting or pivoting the items I want to move together, i would appreciate any mods to my code to make it reliable. As I said before, it worked acceptably (just) on my old computer. |
| ||
I also imagine using a rotated cylinder for the gun may have caused it to shoot off in Z direction, therefore rendering the above code to be meaningless. What a mess LOL |
| ||
Yes, if you delete the cylinder rotation by 90deg line, the gun object doesn't shoot off. It looks weird having a gun look like a vertical cylinder, but the program behaves a little better, i.e. moves from keypresses. Even then, the camera doesn't rotate correctly. |
| ||
First thing i spotted that is not a good approach : You can indeed define collisions detection and response between "colliders" (the shapes which provoke a collision) and "collidables" (the shapes which receive a collision) each loop if you want to, but you have to do that before turning moving an entity which use one or several ellipsoid colliders. for example : mainloop start define ellipsoid colliders (with entityradius and entitytype) define collidabls (with entitytype) define collisions detection and response (with collisions) turn move the entities detect collisions, reposition (with updateworld) get infos about the collisions (with countcollisions, collisionentity, etc...) render mainloop end Another thing : to be able to position rotate each entity which has one or several ellipsoid colliders attached to it, you have to either use restentity() before you position rotate the entity (but unfortunately it does not always work, i don't know why...) or you can destroy all ellipsoid colliders attached to an entity, then position rotate the entity, then recreate the ellipsoid colliders. If you don't do that, some ellipsoid colliders may get stuck somewhere and then produce weird results. I suggest to try that before anything else. But there may be another error concerning your cylinder for the gun : to be sure that the barrel of the gun points towards the appropriate direction (towards +z), before rotating/turning it, just take a look at which direction it points towards (you can put a small marker at 0,0,0 to see the orientation related to the origine of the 3d world) |
| ||
Thank you Remid, does that mean I can make the camera and bullet non-collidables if I want, seeing as its the gun that collides with objects when moving. The idea with the bullet is to show the gun is firing rather than it needing to necessarily collide with anything. |
| ||
Making the bullet and camera non-collidable seems to have cured the rotation of the camera problem. But the gun only moves in one z direction, the gun appears to "try" to move in the other z direction but seems to be locked from doing so. |
| ||
does that mean I can make the camera and bullet non-collidables if I want, seeing as its the gun that collides with objects when moving. Yes, as you want... For bullets, to detect collisions, instead of using ellipsoid colliders and collidables, you can use linepicks and pickables... |
| ||
Yes, I use entitypickmode to identify targets at centre of screen when within a certain distance and being fired at. What about this inability to move in one of the z-directions, I mean the gun isn't colliding with any thing (as far as I know) and which z-direction gets blocked varies from time to time. |
| ||
Doing a CountCollisions print for the gun object in my full program indicates it as 1 (i.e. permanently colliding with something, presumeably the groundplane??). The moment its blocked in a particular z-direction it goes up to 2 (for some inexpilable reason, a nonexistent invisible barrier of some kind). |
| ||
When countcollisions() returns 1, (or more but this is very rare), you can get the collidable which was involved in the collision by using collisionentity() collisionentity() will return the reference of the collidable you can then use this reference to interact with it. An example here : http://www.blitzbasic.com/codearcs/codearcs.php?code=3141 Considering what you have posted so far, your problem is most likely not a bug because of Blitz3d but rather an error in your code... |
| ||
Towards the end of my while loop, I set the EntityColor of the offending entity handle to red plus a print saying whether the offending item was in view of the camera, i.e. using EntityInView and lo and behold a building at starting point was red, then the sky went red and a bridge I stood on went red. The EntityInView print kept going on and off depending where I was facing. Is it something to do with the EntityRadius values of various "scenery" objects that are causing this problem. I'm still none the wiser... |
| ||
after a thorough reading of your code (first reading was real quick !), i see another thing which may cause problem with collisions detection and response : -you don't size your meshes and ellipsoids correctly : in blitz3d, when you create a cube/cylinder/cone/sphere, a size of 1.0,1.0,1.0 corresponds to a width,height,depth of 1.0 from the center of the mesh (so the mesh will measure 2.0,2.0,2.0) -and a radius of 1.0 will be like having a sphere of 2.0,2.0,2.0 so if the barel of your gun measures 0.05,0.05,0.3, you want to use scalemesh(barel,0.05/2,0.05/2,0.3/2) so for a smaller bullet than the barel, let's say 0.04,0.04,0.04, you want to use scalemesh(bullet,0.04/2,0.04/2,0.04/2) and for the radius of your bullet, you want to use 0.02 (half of 0.04) then when you want to shoot a new bullet, you have to create the ellipsoid collider after having positionned/oriented the bullet in the barel, else the bullet may get stuck somewhere. so yeah plenty of errors in your code, not Blitz3d's fault... |
| ||
Thats actually what I wanted to hear, Remid. After making the camera and bullet non-collidables, you've managed to solve half of my woes. Its back to the drawing board for me for awhile. Thank you for all your help, much appreciated. |
| ||
Amazingly, it all works okay if I delete the sky plane (Moves in all directions correctly). Only problem is I want the sky plane. I tried increasing its height 10 fold but still gives me the same problem. Thanks to everyone. Now I just need to figure out how to incorporate the sky... |
| ||
...Of course, I can also make that non-collidable! |
| ||
I think that your problem may be caused by the use of entitytype a little too much (which is used for collisions detection and response) An alternative is to put the "group" (not collisions group, just a group of things) name in the entityname, like so : "sky-1" where sky is the name of the group and 1 is the index/handle of the entity (you will need the group and the index/handle of an entity if you want to be able to access it directly (after a collision or a pick)). See these examples : with dim arrays : http://www.blitzbasic.com/codearcs/codearcs.php?code=3094 with customtypes : http://www.blitzbasic.com/codearcs/codearcs.php?code=3095 |
| ||
Thank You for those awesome examples, RemiD. As you probably guessed, I'm relatively new to all this. I have tinkered with Direct3D a fair amount in the past, unsuccessfuly with C++ but Blitz3D certainly eased the learning curve and accelerated achievements. I have a bloated lash up of a first person shooter throwing other peoples assets together with my simple crude level. I tried Darkbasic a little but soon stumbled on Blitz3D which is an amazing, less verbose engine. I have another question about playing sound effects but i guess thats for another thread. |
| ||
Well, welcome to the Blitz3d world, there are plenty of examples in the codearchives and on the forums, have fun :) |