yes you can in that case SetObjectRotation(projectiledirbox, GetCameraAngleX(1), GetCameraAngleY(1), GetCameraAngleZ(1));
projectilebox in the above is just where the player would be and their current world angle but an object is needed so as it can be moved on z for calculations
Apologies the above might be a little confusing as I used it for the enemy to point at the player hence the current look at commands pointing at a player.id
replace
SetObjectPosition(projectileDirBox,x#,y#,z#)
SetObjectLookAt(projectiledirbox,GetObjectWorldX(player.ID),GetObjectWorldY(player.ID),GetObjectWorldZ(player.ID),0)
MoveObjectLocalZ( projectileDirBox, 1.0 )
with
SetObjectPosition(projectileDirBox,x#,y#,z#)
SetObjectRotation(projectiledirbox, GetCameraAngleX(1), GetCameraAngleY(1), GetCameraAngleZ(1));
MoveObjectLocalZ( projectileDirBox, 1.0 )
and if you know the object you are aiming at great for the enemy you can use this function where mytarget is the id of the target and objecteId is the object firing the bullet
function shootbullet(objectId as integer,initialSpeed as float, mass as float,myTarget as target)
//To move dynamic physics bodies we need to apply velocity to the physics body.
gunPositionVec= CreateVector3(GetObjectWorldX(objectId),GetObjectWorldY(objectId),GetObjectWorldZ(objectId)) //im using the camera position as the gun position
//Create a tempory projectile block to calculate movement vectors of bullets
projectileDirBox as integer
projectileDirBox = CreateObjectBox( 1.0, 1.0, 1.0 )
FixObjectToObject(projectileDirBox,ObjectId)
x#=GetObjectWorldX(projectileDirBox):y#=GetObjectWorldY(projectileDirBox):z#=GetObjectWorldZ(projectileDirBox)
FixObjectToObject(projectileDirBox,0)
SetObjectPosition(projectileDirBox,x#,y#,z#)
SetObjectLookAt(projectiledirbox,GetObjectWorldX(myTarget.ID),GetObjectWorldY(myTarget.ID),GetObjectWorldZ(myTarget.ID),0)
MoveObjectLocalZ( projectileDirBox, 1.0 )
projectileDirVec = CreateVector3( GetobjectWorldX( projectileDirBox )-GetVector3X( gunPositionVec ), GetobjectWorldY( projectileDirBox )-GetVector3Y( gunPositionVec ), GetobjectWorldZ( projectileDirBox )-GetVector3Z( gunPositionVec ) )
//DeleteObject( projectileDirBox )
missile as integer
missile = CreateObjectSphere(.4,5,5)
SetObjectColor(missile, 0,255,0,255 )
SetObjectLightMode(missile,0)
SetObjectPosition(missile, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ) )
SetObjectRotation(missile,GetObjectAngleX(projectileDirBox),GetObjectAngleY(projectileDirBox),GetObjectAngleZ(projectileDirBox)+180)
//RotateObjectLocalZ(missile,90)
DeleteObject( projectileDirBox )
//3D Physics code
Create3DPhysicsDynamicBody(missile )
//SetObjectShapeSphere( bullet )
SetObject3DPhysicsMass(missile, mass )
SetObject3DPhysicsLinearVelocity(missile, projectileDirVec, initialSpeed )
myItem as bullet
myItem.ID = missile //the object id of the bullet
myItem.time = timer() //timer is used to set there life time as bullets will die off after so long
playerBomb.insert(myItem) //update bullet arrow as there is unlimeted bullets
//inc bulletCount //used for a bullet counter to check if theyve timed out or not
deletevector3(projectileDirVec)
deletevector3(gunPositionVec)
endfunction
fubar