I suck at this I admit it.. I have spend way to long trying to come up with a solution for how to shoot in a 3d world. Truly have tried all over youtube and looking at all I can get my hands on but this really eludes me, Could someone ~please~ take a look at my code here (you can see I tried) and help me with how to shoot straight ahead as my bullets only want to go to one place, and I cannot work out why. :'(
So far, I have a player ship... moveable with the WASD (I can tweak this part later)
I have an enemy (ground based).. he shoots at the player ship fine (It works but I think the approach is totally wrong)... and the enemy moves around on the ground...once again it works... LOL I know you guys are gunna laugh at the way I did this, but. well anyway any help would be appreciated.
Cheers all.
Graphics3D 1024,768:SetBuffer BackBuffer():camera = CreateCamera():light = CreateLight()
AppTitle "Tiny Galaxy"
;Player
player=CreateCube():ScaleEntity player,.5,.2,1:PositionEntity player,0,0,5
tail=CreateCube():ScaleEntity tail,.1,.2,.2:PositionEntity tail,0,.4,4.2
EntityParent tail,player
st=0;player shoot timer
pfired=0:prange=0:pst=0 pshoot=0
;angle of player turn
wy=.5:sy=.5:ax=.5:dx=.5
EntityParent camera,player
;ENEMY
ex=-10
ey=-10
ez=15
enemy=CreateCube():ScaleEntity enemy,.5,.5,.5:PositionEntity enemy,ex,ey,ez
EntityColor enemy,255,120,120
;EMARKER
emarker=CreateCube():ScaleEntity emarker,1,1,1:PositionEntity emarker,200,0,200
;missile
ebullet=CreateCube()
ScaleEntity ebullet,.1,.1,.5
EntityColor ebullet,255,0,0
PositionEntity ebullet,ex,ey,ez
shoot=0:efired=0:ereload=0
;GROUND
ground=CreateTerrain(512)
PositionEntity ground,-200,-10,0
gtex=LoadTexture("grass.bmp")
EntityTexture ground,gtex
t=0;Enemy bullet timer
; >>>>>>>>>>>>>>>>>>>> BEGIN LOOP <<<<<<<<<<<<<<<<<<
While Not KeyDown(1)
; PLAYER CONTROLS
; PITCH ...UP and DOWN
If KeyDown(17) Then pitch# = pitch# - wy+.5 ;W
If KeyDown(31) Then pitch# = pitch# + sy-.5 ;S
; YAW ...LEFT RIGHT
If KeyDown(30) Then yaw#=yaw#+ax+.5 ;A
If KeyDown(32) Then yaw#=yaw#-dx-.5 ;D
; ROLL...TILT LEFT RIGHT
If KeyDown(16) Then roll#=roll#+.2 ;Q
If KeyDown(18) Then roll#=roll#-.2 ;E
MoveEntity player,0,0,.02
RotateEntity player,pitch#,yaw#,roll#
;ENEMY MOVEMENT
emt=emt+1
If emt>800+Rnd(800)
FreeEntity emarker
emx=Rnd(-100,100):emz=Rnd(-100,100)
emarker=CreateCube ()
ScaleEntity emarker,.2,10,.2
PositionEntity emarker,emx,-10,emz
emt=0
EndIf
PointEntity enemy,emarker
MoveEntity enemy,0,0,.01
;ENEMY FIRE CONTROL
If efired=0 PointEntity ebullet,player
t=t+1:If t>5 shoot=1
If EntityDistance (ebullet,player)<20 And shoot=1:efired=1:EndIf
;MOVE EBULLET
If efired=1 MoveEntity ebullet,0,0,.05:erange=erange+1
;ENEMY EBULLET RANGE AND RESET
If erange>500 efired=0:t=0:shoot=0:FreeEntity ebullet
;MAKE NEW BULLET
If erange>500
ebullet=CreateCube()
ScaleEntity ebullet,.05,.05,.3
EntityColor ebullet,255,0,0
ex=EntityX(enemy):ey=EntityY(enemy):ez=EntityZ(enemy)
PositionEntity ebullet,ex,ey,ez
erange=0
EndIf
;PLAYER SHOOTING
x=EntityX(player):y=EntityY(player):z=EntityZ(player)
target=CreateCube()
PositionEntity target,x,y,z+100
pst=pst+1
If pst>10 pshoot=1 pst=0 Else pshoot=0
If KeyDown(57) And pshoot=1
bullet=CreateCube()
ScaleEntity bullet,.1,.1,.02
EntityColor bullet,255,0,250
PositionEntity bullet,x,y,z
pfired=1
EndIf
;MOVE EBULLET
If pfired=1 PointEntity bullet,target MoveEntity bullet,0,0,.5:prange=prange+1
;EBULLET RANGE AND RESET
If prange>400 pfired=0 prange=0 FreeEntity bullet
RenderWorld
Flip
Wend
Have you tried looking at all the examples that come with b3d? The're are many have shooting in 3d space.
Hi there, yes I had a look at the examples. The closest thing I can see that does what I want to do is an asteroids clone. But how on earth I would translate the shoot code into my base level game here is beyond me.
The below are the fundamentals of the things I feel I need to know how to do to start making the game I want to. I understand 95% of it, to get by.
Collisions... Yes understood
Randomization Yes understood
Imposting models Yes undewrstood
Texturing Yes understood
Movement in 3d Good enough for now and I can understand what I hjave typed in in the example I posted.
Distance to objects Yes, easy love it in Blitz3d
for/next/loops Yes all good.
AI I can bumble through it ok. I have spent a few years in Gamemaker studio GML and have
brought a few things there to what I try to program here, and it has helped a lot.
COS/SIN/TAN Don't need it just yet, but have enough examples I can work with for some AI patterns.
Types I think I can use this somehow in the shooting area, but for now I mainly use for collisions.
fields Not understood yet.
BUT
Shooting and Repeated shooting <<< I have not yet found an example I can actually understand.
What I am trying to do is have models shoot at each other, as you can see I
managed a dodgey version in the above example, they enemy however
only fires one bullet at a time... great but limited. I also need to know how
the player can fire so the fired bullets don't stop everytime the fire button is re-pressed. And aim where the ships facing.
I can't tell you guys how many hours I have tried to work it out. I have made 3 fair sized games now... one I really like where I have a few animated
zombies walking around in 3d, and as soon as I manage to find out how the devil I can shoot at the bastar@$ I will be able to move on to bigger and
better projects. I didn't come here on a whim, I have put a lot of time into this and would appreciate if anyone has SIMPLE code or knows of an easy example I could follow
as it's driving me bonkers here.
Cheers all.
well this is kinda interesting.... so I see the reddish cube on the ground firing at the plane--- moved plane with WASD for pitch and turn. It looks to me like the white blocks are created in the distance based on the flight path of the airplane...this is weird.
The airplane only shoots white cube bullets from one side (possible positive z from the airplane center point)- regardless of which way the plane is facing. So first off there needs to be code to make the bullets shoot from the planes current facing (yaw and pitch).
(https://www.syntaxbomb.com/proxy.php?request=http%3A%2F%2Fi67.tinypic.com%2Fbk5kl.jpg&hash=05b46381392c450378de40c5a7b09dc5f86b85a8)
Hi there,
The blocks are just a couple of cubes joined together as a 3d model... that just has the camera fixed on them. I know its not much at the moment but it's all placeholding until I can get this shooting thing worked out before I go to much further.
I have some reasonable ideas if I can just get over this hurdle. :)
ok I know that.. so you need to pick the lead cube of the plane thing and have the bullets fly from the lead cubes current x,y,z location and have the bullet vector align with the plane current yaw,pitch, and roll...
the pic I added shows the strange cube model of the planes flight path
Please be patient and let others in the group read your message.... then we can help you
..regarding B3D and FPS shooter framework, you should not look further than this, and probably after having this, any question about current topic should be considered an insult :) ... credits goes to Rob Cummings..
(https://s22.postimg.cc/ef0otqb01/Screenshot_-_7_17_2018_6_06_45_PM.png)
..whole project source/media in attachment..
The main problem I see here is that when player shoots a second bullet, the data for the first bullet is replaced, stopping it in its tracks. So you either need to 1) Check if a bullet is fired and delete it before creating a new one, or 2) define a bullet type, create a new instance every time one is fired, and iterate over the list using For/Each to move all the bullets each frame.
If you want to manage / update several different bullets, you need to learn to store the instances in a custom type or dim array... Several examples in the codes archives !
It might be good to learn about arrays and types first. The documentation in b3d is pretty allright.
Basically if you can fire 1 bullet then you just need to create more of the same variables and objects needed for those. Arrays are variables that have a number(depth) you can store enough with them. You could use a currentbullet variable to know which bullet is currently for update of for launching.
Types are a more advanced arrays and contain these fields that are basically variables. One type instance holds all the field variables that you could think of. Each instance of a type is stored inside a list.
So experiment and learn a little bit about arrays and types first :) So dig into the code archives and b3d documentation :)
All the modes give me the message "Unable to created 3D scene"
for some reason.
..try to set supported screen size of your monitor without fullscreen...it may be that (when i set full 4K resolution, same error appear)..do something as 800x600 for start , which should work on anything..
I still get the same message.
Does this require some special version of DirectX?
When I change the Graphics3D to Graphics, the program crashes with no message.
..you have to use Graphics3D..im not sure what sort of problems you actually may have..its hard to say without knowing your machine specifications..far as i can tell, it runs just fine on 10 years old machine (tested just now)..
..here is the compiled EXE in attachment...copy it where you have extracted media from zip file i have posted before and run it and see is it working..its set to 1024x600, windowed..
I ran your file and the AVAST software sent it to their cyber labs for investigation.
Unbelievable
..probably because its EXE inside, but i have scanned it with ESET so it should be just fine..
Avast returned a message saying that the file was OK but I still cannot get the program to run with either method.
It might be some direct X companion code that is required or similar.
It runs but stops at another point now. I'm including a screen shot to show where it stops.
I know it's a 3D command that requires the different mode but that one does not work for some reason. I'll also try reinstalling the program again.
cant see what your demo is in but the graphic mode should be like this to work in WIN 10;
Graphics3D 1024,768,32,2
You have to specify 32 bit graphics, and of course it is alway better to set a windowed ( eg. "2") screen instead of full display.
..i really hope you are not joking..anyway, change this as it was mentioned twice already..
(https://s33.postimg.cc/td7yyk3fz/fps_ERR.png)
Try running this little snippet here. It will print all the graphics modes your system is capable of. If your system is like mine, it will not support 16 bit color.
; CountGfxModes3D()
; -----------------
Graphics 800,600,0,2
For i=1 To CountGfxModes3D()
Print "Mode "+i+": ("+GfxModeWidth(i)+"x"+GfxModeHeight(i)+"x"+GfxModeDepth(i)+")"
Next
WaitKey()
oh come on..... this is not a debate- 16 bit mode does not work in Win 10, just make sure it is 32 bit mode. I have gone thru many of my old B3D programs- they do not work in 16 bit or in unspecified bit mode- 32 bit only...
Quote from: Naughty Alien on July 26, 2018, 07:35:34
..i really hope you are not joking..anyway, change this as it was mentioned twice already..
(https://s33.postimg.cc/td7yyk3fz/fps_ERR.png)
I used your syntax and got the message that the software could not create a 3D scene
Quote from: TomToad on July 26, 2018, 11:17:25
Try running this little snippet here. It will print all the graphics modes your system is capable of. If your system is like mine, it will not support 16 bit color.
; CountGfxModes3D()
; -----------------
Graphics 800,600,0,2
For i=1 To CountGfxModes3D()
Print "Mode "+i+": ("+GfxModeWidth(i)+"x"+GfxModeHeight(i)+"x"+GfxModeDepth(i)+")"
Next
WaitKey()
I used this code and the screen just stays blank.
@Mikey
Whats the OS and gpu, gpu driver version in the system that is failing?
Could it possibly be a corrupt install? Try reinstalling blitz3d and see if that helps. Also remember that from Win Vista and later, you need to save the source somewhere other than the"Program files" directory to compile.
It does sound strange. It seems as though there's no (or incorrect) 3d drivers installed, I wonder, but doubt, if monitor drivers would play a part in things not working. I'm not so sure on a corrupt install ( but of course it could be - as that's the nature of a corrupt install :) ) as I get the impression that it builds and runs the exe(s) from the editor?
The save process takes place just before the build takes place (pretty standard logic). The build takes place all in RAM and is executed from RAM too. It's only when you want to build an exe does it actually drop an executable file on to the hard drive.
Quote from: col on July 28, 2018, 14:48:32
@Mikey
Whats the OS and gpu, gpu driver version in the system that is failing?
I'm running windows 7 Professional, standard install, nothing fancy.
8GB of ram
Quote from: TomToad on July 28, 2018, 17:25:47
Could it possibly be a corrupt install? Try reinstalling blitz3d and see if that helps. Also remember that from Win Vista and later, you need to save the source somewhere other than the"Program files" directory to compile.
I installed the software on a drive other than C: and the source listings are going into a folder other than the program files folder. I've never saved files there for portability reasons.
Can you post a pic showing the 'Adapter' tab selected too?
..this is really weird..
Why are you running your graphics card at 16 bit color? Any system built in the last 10 years would work much more efficiently at 32 bit. Possibly the source of your error? Try running your monitor at 32 bit and use 32 bit in B3D.
Quote from: col on July 30, 2018, 03:25:47
Can you post a pic showing the 'Adapter' tab selected too?
Here that is and its an odd configuration. Much different from the machine that was replaced by this one.
Quote from: TomToad on July 30, 2018, 18:53:06
Why are you running your graphics card at 16 bit color? Any system built in the last 10 years would work much more efficiently at 32 bit. Possibly the source of your error? Try running your monitor at 32 bit and use 32 bit in B3D.
I posted the image of all the modes.
I tried them all. Any other program works in all the modes except for this program, which is why this event is odd.
..can you run DXDIAG(type DXDIAG in the lower-left search box on desktop) and then take screenshot of that and post here..
..take screenshots of this two tabs..
(https://s33.postimg.cc/f01r8pzjz/dxdiag.png)
(Have not read the previous pages of this thread...so excuse if I duplicate stuff)
(https://www.syntaxbomb.com/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FMbJximU.png&hash=e5714b73767b1446780754bc4dc7ee547f253bc4)
-> missing vendor specific gpu driver
-> no (or up to none) hw acceleration
-> issues with OGL/D3D
If it is an IGP (chip on the mainboard) then install mainboard drivers.
If it is a GPU card, install drivers for the GPU.
When booting up your computer you most often see the GPU chip name on the top left of the screen - before mainboard information ("bios post messages" or "mainboard logo") is displayed.
Internal IGP: you connected your screen to a cable socket right next to USB and audio sockets.
External: there are some metal slots below the usb/audio/whatever-sockets (90 degrees turned compared to the alignment of these mainboard sockets). One of these slots (or two..) is occupied with your screen-cable-socket (and hdmi and so on).
Hardware can get identified via the "vendor ID" of the chip - which Windows exposes. But as this is a more complicated job, I would postpone that for later.
bye
Ron
It looks like its a driver issue. I'd go to AMD/ATI and try out their 'auto-detect' tool to download and install another more dedicated driver. If it doesn't detect anything then do as Naughty Alien suggests for us to see what GPU Windows has detected - There are many tools for this and as you probably already have DxDiag installed it makes sense to use it.
If that fails to help then we can do as Derron says and use the PID and VID to isolate the GPU.
It's running
It was the drivers. What folder hold the .b3d meshes and similar?
I think they'll either be in the examples local source code folder or in the '<Blit3DInstallationFolder>/Media' folder.