firing bullets
Blitz3D Forums/Blitz3D Beginners Area/firing bullets
| ||
I have designed a level using Quill 3d Map builder. In my game I have a gun placed at the bottom center of the screen. The gun is a child of the Camera and moves or pivots whenever the camera moves. I need some code to get the gun firing bullets in whatever direction the camera is pointing. Can anyone help? |
| ||
Use:- PositionEntity bullet, EntityX# ( gun, True ), EntityY# ( gun, True ), EntityZ# ( gun, True ), True RotateEntity bullet, EntityPitch# ( gun, True ), EntityYaw# ( gun, True ), 0.0, True to get the bullet in the right position and pointed in the right direction, and then:- MoveEntity bullet, 0.0, 0.0, move_increment# to move the bullet in the direction it's pointed in. 'move_increment#' should hold the amount you want to move the bullet by during each update (if you're using deltatime to control the game-speed then you should apply it to this variable). If the collision state of the bullet has been set before you move it into its starting position (as will be the case if you're copying from a source bullet with a set collision state) you will need to do a 'ResetEntity bullet' after moving it, to re-prime its collision state and stop it from colliding with any collision enabled items between the source position and the gun's position. If you want your bullet to fire from the gun's firepoint without the bullet firing through any walls that the gun may be poking through (assuming the firepoint pokes out beyond the game characters collision zone) then move it to a point well within the collision zone, do a ResetEntity on it, and then move it to the firepoint. |