Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bullet Code?
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#2
RE: Bullet Code?

Try this in the OnAction function of the map script:

void OnAction(int alAction, bool abPressed)
{
    if (alAction == eAction_Interact && abPressed)
    {
        // Check to see if player is holding a gun object. This value
        // would be updated when the player picks up, draws, or
        // holsters the gun in the corresponding callbacks for those events
        if (mbHoldingGun)
        {
            // "Fire" a bullet in the direction the player is looking with a max range of mfGunRange
            cLuxClosestEntityData pData;
            if (cLux_GetClosestEntity(mpCamera.GetPosition(), mpCamera.GetForward(), mfGunRange, 0, true, pData))
            {
                tString sEntityName = pData.mpEntity.GetName();
                
                // Handle gunshot on entity with the name stored in sEntityName
            }
        }
    }
}

Rather than fire an actual object (i.e. my previous suggestion), this should simplify the solution by just doing a simple ray trace to see which entity would be in the way of the gun.
(This post was last modified: 06-02-2016, 05:54 AM by Abion47.)
06-02-2016, 05:52 AM
Find


Messages In This Thread
Bullet Code? - by A.M Team - 06-01-2016, 11:40 PM
RE: Bullet Code? - by Abion47 - 06-02-2016, 05:52 AM
RE: Bullet Code? - by A.M Team - 06-02-2016, 07:56 AM
RE: Bullet Code? - by Abion47 - 06-02-2016, 08:50 AM
RE: Bullet Code? - by A.M Team - 06-02-2016, 12:16 PM



Users browsing this thread: 2 Guest(s)