My Unreal 4 Tour 03 add key events

Source: Internet
Author: User

Long time not to update the blog, the recent busy not updated, years ago estimates can only be intermittent updates. This section I want to discuss under Unreal four button trigger.

First, we will set to W , A, S , D Key axis Mapping .

1. In the Edit menu on the Project Settings , Click .

2. The engine title of the project Set Label the left , Click input .

3. In binding , Please click the plus sign Next Shaft Mapping .

4. " Moveforward " appearance of text Field , then Click the arrows to of the text box left Expand combined Shaft Options .

5. In Drop -down menu, Select W You're Input Settings now it should look like below :



6. Now click the + sign to add the next moveforward

7. In the second down menu, enter-1 if

8. Close the Settings screen

9. Go to vs or Xcode in Fpscharacter. H. Add

    protected :        Virtual void Setupplayerinputcomponent(class uinputcomponent* inputcomponent) override ;
    //handles Moving Forward/backwardUfunction()    voidMoveforward(floatVal);    //handles strafingUfunction()    voidMoveRight(floatVal);
10 adding in CPP

  voidAfpscharacter::setupplayerinputcomponent(Uinputcomponent*Inputcomponent)    {        //Set up gameplay key bindingsInputcomponent->Bindaxis("Moveforward", This,&Afpscharacter::Moveforward);Inputcomponent->Bindaxis("MoveRight", This,&Afpscharacter::MoveRight);    }
    voidAfpscharacter::Moveforward(floatValue)    {        if ( (Controller!= NULL) && (Value!= 0.0f) )        {            //Find out which-forwardFrotator Rotation=Controller->Getcontrolrotation();            //Limit pitch when walking or falling            if (Charactermovement->Ismovingonground() ||Charactermovement->Isfalling() )            {Rotation.Pitch = 0.0f;            }            //Add movement in that direction            ConstFvector Direction=Frotationmatrix(Rotation).Getscaledaxis(Eaxis::X);Addmovementinput(Direction, Value);        }    }


    voidAfpscharacter::MoveRight(floatValue)    {        if ( (Controller!= NULL) && (Value!= 0.0f) )        {            //Find out which            ConstFrotator Rotation=Controller->Getcontrolrotation();            ConstFvector Direction=Frotationmatrix(Rotation).Getscaledaxis(Eaxis::Y);            //Add movement in that directionAddmovementinput(Direction, Value);        }    }
Well, the mutation will run and you'll see your character move.

My Unreal 4 Tour 03 add key events

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.