Greetings,
Here's an example code:
rem In the following example, the bullet starts at the positions:
rem sx# for the X axis
rem sy# for the Y axis
rem sz# for the Z axis
rem
rem and ends at:
rem ex# for the X axis
rem ey# for the Y axis
rem ez# for the Z axis
rem
rem Then the "lzr" object below, would be your bullet hole
rem
rem This example comes mostly from the "3rd_shooter.dbpro" example
rem that comes with your package. In that example, it uses this
rem code to place the laser sight in front of the soldier
rem
rem Also, the "object" below would be the mesh you were testing
rem the bullet against
obj_hit = RayIntersectObjectPRO( object, 2, sx#, sy#, sz#, ex#, ey#, ez#)
if obj_hit
rem get ray feedback data
rem Gets the positions the ray intersected the object
hitX# = RayHitPosPRO("X")
hitY# = RayHitPosPRO("Y")
hitZ# = RayHitPosPRO("Z")
rem Gets the normals of the surface that was intersected
hitNX# = RayHitNormPRO("X",0)
hitNY# = RayHitNormPRO("Y",0)
hitNZ# = RayHitNormPRO("Z",0)
rem Passing the normals in, get the Y angle we need to rotate our decal object
yrot# = Vec2YawPRO(hitNX#, hitNY#, hitNZ#)
rem Passing the normals in, get the pitch we need to adjust the decal by
pitch# = Vec2PitchPRO(hitNX#, hitNY#, hitNZ#)
rem Push the hit positions away from the surface a bit
hitX# = hitX# + (hitNX# * 0.20)
hitY# = hitY# + (hitNY# * 0.20)
hitZ# = hitZ# + (hitNZ# * 0.20)
rem rotate the object to 0,0,0 (this should always be done before using the
rem next commands)
rotate object lzr, 0, 0, 0
rem Rotate the decal into position
yrotate object lzr, yrot#
pitch object up lzr, pitch#
rem Position the decal at the final hit positions
position object lzr, hitX#, hitY#, hitZ#
endif
You also want to look at the "3rd_shooter.dbpro" example that comes with your package. It uses the ray cast command to place the laser on the wall in front of the soldier.